Reputation: 263
I want to convert following date and time, into a timestamp 13 digits. Note I use strict mode.
Date:
Thu Jun 01 2017 00:00:00 GMT+0200 (CEST)
Time: 03:00
I tried to use Date.parse() but it was not working. What is the best way to do this?
Upvotes: 0
Views: 184
Reputation: 1738
Create the date object, add time as you wish and then use the getTime() function:
"use strict";
var date = new Date('Thu Jun 01 2017 00:00:00 GMT+0200 (CEST)');
date.setHours(parseInt('03'),[parseInt('00')]); //apply hours and minutes
console.log(date.toString());
console.log(date.getTime()); //use of getTime()
Upvotes: 0
Reputation: 889
console.log(+new Date("Thu Jun 01 2017 00:00:00 GMT+0200 (CEST)"))
Upvotes: 0
Reputation: 2070
You can use the getTime
function:
console.log(new Date('Thu Jun 01 2017 00:00:00 GMT+0200 (CEST)').getTime());
Upvotes: 2