Created
November 1, 2015 23:41
-
-
Save oscarmorrison/fc10377e3824f0f6792b to your computer and use it in GitHub Desktop.
Javascript get current date
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
//"YYYY-MM-DD hh:mm" | |
function zeroFill(i){ | |
return (i<10 ? '0' : '') + i; | |
} | |
var getDate = function(){ | |
var d = new Date(); | |
var year = d.getFullYear(); | |
var month = zeroFill(d.getMonth()) | |
var day = zeroFill(d.getDate()) | |
var hour = zeroFill(d.getHours()) | |
var min = zeroFill(d.getMinutes()) | |
return year+'-'+month+'-'+day+' '+hour+':'+min; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment