Search code examples
javascriptjquerydatedatetimeunix-timestamp

Convert normal date to unix timestamp


How can I convert normal date 2012.08.10 to unix timestamp in javascript?

Fiddle: http://jsfiddle.net/J2pWj/




I've seen many posts here that convert it in PHP, Ruby, etc... But I need to do this inside JS.


Solution

  • Math.floor(new Date('2012.08.10').getTime() / 1000)
    

    Check the JavaScript Date documentation.