Javascript 将日期/时间转换为时间戳

Javascript 将日期/时间转换为时间戳,javascript,angular,Javascript,Angular,我想把下面的日期和时间转换成13位的时间戳。注:我使用严格模式 日期: 2017年6月1日星期四00:00:00 GMT+0200(CEST) 时间: 03:00 我尝试使用Date.parse(),但它不起作用。执行此操作的最佳方法是什么?请尝试下面的代码 console.log(newdate().getTime())请尝试下面的代码 console.log(newdate().getTime())您可以使用getTime功能: console.log(新日期('Thu Jun 01

我想把下面的日期和时间转换成13位的时间戳。注:我使用严格模式

日期:

2017年6月1日星期四00:00:00 GMT+0200(CEST)

时间: 03:00

我尝试使用Date.parse(),但它不起作用。执行此操作的最佳方法是什么?

请尝试下面的代码

console.log(newdate().getTime())请尝试下面的代码


console.log(newdate().getTime())您可以使用
getTime
功能:


console.log(新日期('Thu Jun 01 2017 00:00:00 GMT+0200(CEST)).getTime()您可以使用
getTime
功能:


console.log(新日期('Thu Jun 01 2017 00:00:00 GMT+0200(CEST)).getTime()创建日期对象,根据需要添加时间,然后使用以下功能:
“严格使用”;
var日期=新日期(“2017年6月1日星期四00:00:00 GMT+0200(CEST)”;
date.setHours(parseInt('03'),[parseInt('00')])//应用小时和分钟
log(date.toString());

log(date.getTime())//使用getTime()
创建日期对象,根据需要添加时间,然后使用以下函数:
“严格使用”;
var日期=新日期(“2017年6月1日星期四00:00:00 GMT+0200(CEST)”;
date.setHours(parseInt('03'),[parseInt('00')])//应用小时和分钟
log(date.toString());

log(date.getTime())//使用getTime()
是否需要历元时间戳??是否需要历元时间戳??
console.log(+new Date("Thu Jun 01 2017 00:00:00 GMT+0200 (CEST)"))