Javascript equivalent of php's strtotime()?

后端 未结 8 1246
無奈伤痛
無奈伤痛 2020-11-27 19:33

In PHP, you can easily convert an English textual datetime description into a proper date with strtotime().

Is there anything similar in Javascript?

8条回答
  •  鱼传尺愫
    2020-11-27 19:58

    I found this article and tried the tutorial. Basically, you can use the date constructor to parse a date, then write get the seconds from the getTime() method

    var d=new Date("October 13, 1975 11:13:00");
    document.write(d.getTime() + " milliseconds since 1970/01/01");
    

    Does this work?

提交回复
热议问题