【发布时间】:2015-03-02 17:42:17
【问题描述】:
设本地日期时间为local : Mar 10 2014 11:52:50 GMT+0530
在 javascript 中将其转换为 UTC 纪元时间:
var epochtime=Date.UTC(2014,2,10,11,52,50);
output : 1394452370000
现在将其转换回本地日期:
var utcSeconds =1394452370000;
var d = new Date(0); // The 0 there is the key, which sets the date to the epoch
d.setUTCSeconds(utcSeconds);
alert(d);
output : Fri Jun 09 46158 06:03:20 GMT+0530
但需要的输出是: Mar 10 2014 11:52:50 GMT+0530
请有人找出问题所在..?
【问题讨论】:
标签: javascript date utc epoch date-conversion