Created
July 10, 2014 00:17
-
-
Save melbourne2991/da7b60b544e35c4ac153 to your computer and use it in GitHub Desktop.
Converts date objects to YYYY-MM-DD
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
// Converts date object to yyyy-mm-dd | |
var convertDateToString = function(timestamp) { | |
var yyyy = timestamp.getFullYear(); | |
var mm = timestamp.getMonth(); | |
var dd = timestamp.getDate(); | |
if(mm < 10) mm = '0' + mm.toString(); | |
if(dd < 10) dd = '0' + dd.toString(); | |
yyyy = yyyy.toString(); | |
return yyyy + '-' + mm + '-' + dd; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment