jquery - converting date string to utc time format javascript -
i'm trying convert date string format "2014-12-04 12:00am" utc time format of "2014-11-29 01:00:12".
i'm using function
function formatdate(d){ function addzero(n){ return n < 10 ? '0' + n : '' + n; } return d.getutcfullyear() +"-"+ addzero(d.getutcmonth()+1) + "-" +addzero(d.getutcdate()) + " " + addzero(d.getutchours()) + ":" + addzero(d.getutcminutes()) + ":" + addzero(d.getutcminutes()); }
for reason when pick 12am it's set val 12pm , i'm not sure function working on possibilities
try js :
var d = new date("2014-12-04 12:00 am"); var n = d.toutcstring(); alert(n); // output: wed, 03 dec 2014 18:30:00 gmt
you can see link : http://www.w3schools.com/jsref/tryit.asp?filename=tryjsref_toutcstring
Comments
Post a Comment