How to convert this format of time into a timestamp

I just learned JS,. For example, how can this format be changed to a timestamp on January 1, 2018?
I can do this on 2018-01-01, but I don"t know on January 1st, 2018. Thank you for your answer!

Mar.12,2021

my idea is that if the format is fixed, you can convert the year, month and day into-this, and then deal with


January 1, 2018, first convert it to 2018-01-01, and then turn the timestamp


to see what time zone you want "January 1, 2018". If it is a local time zone, you only need new Date ("2018-1-1"). GetTime (). Note that if you use new Date ("2018-01-01"). GetTime (), the result will be different, because the latter will think it is UTC time.
can refer to the same function as https://developer.mozilla.org.


  

day.js,moment.js, only 2kb.

Menu