Skip to content

Instantly share code, notes, and snippets.

@mose
Last active October 24, 2018 13:30
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mose/9108728 to your computer and use it in GitHub Desktop.
Save mose/9108728 to your computer and use it in GitHub Desktop.
Backtick bookmarklet for transforming unix timestamp to human date.
var unix_timestamp = window.prompt("Input a timestamp (ie. 1392879315)", "");
var date = new Date(unix_timestamp*1000);
var utcDate = date.getUTCFullYear() + '-' + (date.getUTCMonth()+1) + '-' + date.getUTCDate() + ' ' + date.getUTCHours() + ':' + date.getUTCMinutes() + ':' + date.getUTCSeconds();
var localDate = date.getFullYear() + '-' + (date.getMonth()+1) + '-' + date.getDate() + ' ' + date.getHours() + ':' + date.getMinutes() + ':' + date.getSeconds();
window.alert("\nUTC: "+utcDate+"\nLocal: "+localDate);
{
"name": "Timestamp from unix",
"description": "For transforming unix timestamp to human date in UTC and local."
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment