Skip to content

Instantly share code, notes, and snippets.

@3ffusi0on
Created February 1, 2016 16:06
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 3ffusi0on/4ff5c506f032f5c7cfea to your computer and use it in GitHub Desktop.
Save 3ffusi0on/4ff5c506f032f5c7cfea to your computer and use it in GitHub Desktop.
Javascript timestamp to date
function timestampToDateString(timestamp){
var a = new Date(UNIX_timestamp * 1000);
var months = ['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'];
var year = a.getFullYear();
var month = months[a.getMonth()];
var date = a.getDate();
var hour = a.getHours();
var min = a.getMinutes();
var sec = a.getSeconds();
var time = date + ' ' + month + ' ' + year + ' ' + hour + ':' + min + ':' + sec ;
return time;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment