Customize date and time in javascript -


i need date , time in format in javascript.

2016/02/17-14:31:36 

currently using

var data = new date(); 

but 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 has leading zero's.


Comments

Popular posts from this blog

gridview - Yii2 DataPorivider $totalSum for a column -

java - Suppress Jboss version details from HTTP error response -

Sass watch command compiles .scss files before full sftp upload -