问题背景:
需要将UTC格式的时间字符串(形如2018-10-30T07:00:00+0000)转换为时间戳(形如1540882800)
问题描述:
var time=new Date("2018-10-30T07:00:00+0000");
发现release(stop remote js debugging)模式下,在这一步就无法进行转换,此时time变量为NaN。
而在debug(remote js debugging)模式下则正常。
问题原因:
在查阅网上相关资料后,定位到有可能是Date类实现的有问题,但是具体问题还不清楚。
知道的同学可以在评论中告知,感谢!
解决方法:
使用moment类进行转换。
let moment = require("moment");
let time = moment("2018-10-30T07:00:00+0000").ValueOf();
// time = 1540882800