Search code examples
javascriptdate

Javascript equivalent of php's strtotime()?


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

Is there anything similar in Javascript?


Solution

  • 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?