I need date and time in this format in javascript.
2016/02/17-14:31:36
Currently I am using
var data = new Date();
But this gives Date {Fri Feb 26 2016 18:38:45 GMT+0530 (India Standard Time)}
I need date and time in this format in javascript.
2016/02/17-14:31:36
Currently I am using
var data = new Date();
But this gives Date {Fri Feb 26 2016 18:38:45 GMT+0530 (India Standard Time)}
var d = new Date(),
year = d.getFullYear(),
month = ('0'+(d.getMonth()+1)).slice(-2),
day = ('0'+d.getDay()).slice(-2),
hour = ('0'+d.getHours()).slice(-2),
minute = ('0'+d.getMinutes()).slice(-2),
second = ('0'+d.getSeconds()).slice(-2);
var dateString = year+'/'+month+'/'+day+'-'+hour+':'+minute+':'+second;
Next time, please google yourself. Thanks.
Edit Now it also has those leading zero's.