Convert normal date to unix timestamp

Stan picture Stan · Aug 10, 2012 · Viewed 204.1k times · Source

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.

Answer

fguillen picture fguillen · Aug 10, 2012
new Date('2012.08.10').getTime() / 1000

Check the JavaScript Date documentation.