Convert YYYY-MM-DD to unix timestamp in Javascript

I need to convert the date to a format, for example. 2011-01-02 - unix timestamp in JavaScript, but doesn’t know exactly how to execute it. I can get the current timestamp using the following functions Math.round((new Date()).getTime() / 1000);, but don’t know how to convert this date to a unix timestamp?

+5
source share
1 answer

You can write new Date("2011-01-02").getTime() / 1000

+16
source

All Articles