Skip to content

Instantly share code, notes, and snippets.

@rwbaker
Created May 22, 2012 13:45
Show Gist options
  • Save rwbaker/2769171 to your computer and use it in GitHub Desktop.
Save rwbaker/2769171 to your computer and use it in GitHub Desktop.
JavaScript: Unix time stamp converter
var myDate = 1337678451;
var date = new Date(myDate*1000);
var hrs = date.getHours();
var min = date.getMinutes();
var sec = date.getSeconds();
var day = date.getDate();
var month = date.getMonth();
var year = date.getFullYear();
console.log(month + '/' + day + '/' + year +' @ ' + hrs + ':' + min + ':' + sec);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment