Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

convert date string to timestamp

is there any way to convert date string Tue Feb 23 2016 20:11:42 GMT+0200 (EET) to timestamp in nodejs?

I was trying to use moment.js with this:

moment('Tue Feb 23 2016 20:11:42 GMT+0200 (EET)', 'YYYY-MM-DD HH:mm:ss').valueOf()

but it returned NaN to me. Maybe its impossible?

like image 366
Daumantas Karpavicius Avatar asked Mar 03 '16 19:03

Daumantas Karpavicius


1 Answers

There's no need for moment.js

var d = new Date("Tue Feb 23 2016 20:11:42 GMT+0200 (EET)");

var timeStamp = d.getTime();
like image 168
Derick Bailey Avatar answered Oct 06 '22 05:10

Derick Bailey