javascript date to unix timstamp and viseversa

Posted: January 28, 2013 in javascript, snippets

I needed to save the date. I sick of the differences in format of the different APIs (sql, phonegap, javascript).

enough is enough.

so i’m moving to using TIMESTAMPs instead…

Current datetime to timestamp

Number(Date.now())/1000

timestamp to datetime

var date = new Date(timestamp * 1000);

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s