[英]How to convert Date into Timestamp
I want to convert date into timestamp 我想将日期转换成时间戳
I have two different format of date Wed May 31 2017 15:33:47 GMT+0530 (India Standard Time)
and 2017-05-31T10:03:47.592Z
. 我有两种不同的日期格式,即
Wed May 31 2017 15:33:47 GMT+0530 (India Standard Time)
和2017-05-31T10:03:47.592Z
。 I want to convert it into timestamp like 1379426880000
. 我想将其转换为
1379426880000
类的1379426880000
。
This is my code. 这是我的代码。
var noOfDays = 5;
var targetDate = new Date();
targetDate.setDate(targetDate.getDate() - noOfDays);
console.log("targetDate date is " + targetDate); //Wed May 31 2017 15:33:47 GMT+0530 (India Standard Time)
console.log(JSON.stringify(targetDate)); // "2017-05-31T10:03:47.592Z"
使用此代码获取时间戳。
targetDate.getTime()
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.