Skip to content

Instantly share code, notes, and snippets.

@bultas
Last active August 29, 2015 14:04
Show Gist options
  • Save bultas/3cdbfc577bd015d55e09 to your computer and use it in GitHub Desktop.
Save bultas/3cdbfc577bd015d55e09 to your computer and use it in GitHub Desktop.
Convert Timestamp to ISO standard format(YYYY-MM-DD)
function convertTimestamp(timestamp) {
function twoDigits(n) {
return n < 10 ? '0' + n : '' + n;
}
var date = new Date(timestamp);
var day = twoDigits(date.getDate());
var month = twoDigits(date.getMonth());
var year = date.getFullYear();
return year + "-" + month + "-" + day;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment