Created
September 23, 2013 20:44
-
-
Save leejaew/6676671 to your computer and use it in GitHub Desktop.
convert unix timestamp to readable format in javascript
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// create a new Date object, foo | |
var foo = new Date; | |
// prompt user for a input (e.g. unix timestamp) | |
//var unixTimestamp = prompt("Enter Unix Timestamp"); | |
// get current system time, getTime() | |
var unixTimestamp = parseInt(foo.getTime() / 1000); | |
// call a function in a constructor context | |
var unixTimeToDate = new Date(unixTimestamp * 1000); | |
console.log(unixTimeToDate); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment