Skip to content

Instantly share code, notes, and snippets.

@madindo
Created August 27, 2014 09:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save madindo/029af56b36d634cd3e01 to your computer and use it in GitHub Desktop.
Save madindo/029af56b36d634cd3e01 to your computer and use it in GitHub Desktop.
Unix to datestamp javascript
var theDate = new Date(content.publish_date * 1000);
var date = theDate.getDate();
var month = theDate.getMonth() + 1;
var month = month < 10 ? '0' + month : month ; //Months are zero based
var year = theDate.getFullYear();
var hour = theDate.getHours();
var min = theDate.getMinutes();
var sec = theDate.getSeconds();
console.log(year + "-" + month + "-" + date + " " + hour + ":" + min + ":" + sec);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment