Skip to content

Instantly share code, notes, and snippets.

@light9
Created September 11, 2013 10:07
Show Gist options
  • Save light9/6521681 to your computer and use it in GitHub Desktop.
Save light9/6521681 to your computer and use it in GitHub Desktop.
From http://stackoverflow.com/questions/847185/convert-a-unix-timestamp-to-time-in-javascript // create a new javascript Date object based on the timestamp
var s = 1378897200; // unix timestamp
var theDate = new Date(s*1000);
//dateString = theDate.toLocaleString();
var year = theDate.getFullYear();
var month = theDate.getMonth() + 1;
var day = theDate.getDate();
var hours = theDate.getHours();
var minutes = theDate.getMinutes();
var seconds = theDate.getSeconds();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment