【发布时间】:2016-03-13 04:38:53
【问题描述】:
我已经检查了这个Using momentjs to convert date to epoch then back to date,但它仍然无法解决我的问题。 在我使用 moment.js 之前,我只是像这样转换了我的纪元时间
场景 1:没有 moment.js
var val = 62460;
var selected_time = new Date(val * 1000);
console.log('Selected epoch is : ', val, 'and the time is ', selectedTime.getUTCHours(), ':', selectedTime.getUTCMinutes(), 'in UTC');
我的控制台日志显示如下 选择的纪元是:62460,时间是 17 : 21,UTC
场景 2:使用 moment.js
var val = 62460;
var selected_time = moment(val).format('hh:mm:ss');
console.log('Selected epoch is : ', val, 'and the time is ', selected_time);
我的控制台日志显示如下 所选纪元为:62460,时间为 UTC 时间 08:01:02
正确的时间是17:21:00。
谢谢。
【问题讨论】:
标签: javascript angularjs ionic-framework momentjs epoch