时刻时区和Ionic2日期选择器
我正在做一个简单的测试(我在法国),使用矩和矩时区(使用矩Angular2库) 不管文档中有什么内容,我都无法获得合乎逻辑的结果时刻时区和Ionic2日期选择器,ionic2,timezone,momentjs,angular-moment,Ionic2,Timezone,Momentjs,Angular Moment,我正在做一个简单的测试(我在法国),使用矩和矩时区(使用矩Angular2库) 不管文档中有什么内容,我都无法获得合乎逻辑的结果 let timezone = moment.tz.guess(); console.log(timezone); // ok: Europe/Paris let now = moment(); let nowFr = now.tz(timezone); // docs: should convert to time zone // both display UTC
let timezone = moment.tz.guess();
console.log(timezone); // ok: Europe/Paris
let now = moment();
let nowFr = now.tz(timezone); // docs: should convert to time zone
// both display UTC format (13pm instead of 15pm local time)
console.log(now.toISOString());
console.log(nowFr.toISOString());
// first show 13pm, second 15pm
// this works, but i'm supposed to be passing ISO string to Ionic2 date picker !!
console.log(now.format());
console.log(nowFr.format());
可能重复的,如所述:.toISOString()
始终以UTC为单位返回时间戳,因此您的代码打印13(法国比UTC早2小时)