Jessika
Jessika

Reputation: 37

Convert from String Date to unix timestamp by moment

I have string accessDate = 20.11.2018 17:28, how to convert this date to unix timestamp by moment, im trying like this - moment(accessDate).unix(), nothing happen, but when im using moment().unix() everything all right

Upvotes: 0

Views: 121

Answers (1)

bar9833625
bar9833625

Reputation: 321

You need to specify the format you are importing the date as. This code is untested but for your case:

moment(accessDate, "DD.MM.YYYY h:mm").unix(); 

You can find more information here.

Upvotes: 2

Related Questions