问题背景:
需要将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。
解决方法:
使用moment类进行转换。
let moment = require("moment");
let time = moment("2018-10-30T07:00:00+0000").ValueOf();
// time = 1540882800
网友评论