Last active
August 29, 2015 14:04
-
-
Save bultas/3cdbfc577bd015d55e09 to your computer and use it in GitHub Desktop.
Convert Timestamp to ISO standard format(YYYY-MM-DD)
This file contains hidden or 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
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