Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/user-interface/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
时刻时区和Ionic2日期选择器_Ionic2_Timezone_Momentjs_Angular Moment - Fatal编程技术网

时刻时区和Ionic2日期选择器

时刻时区和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

我正在做一个简单的测试(我在法国),使用矩和矩时区(使用矩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 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小时)