Created
March 9, 2014 09:27
-
-
Save devm33/9445131 to your computer and use it in GitHub Desktop.
Puts the local time date in a format the W3 is happy with. Disclaimer, I was not made any happier by writing this.
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
var zeroPad = function(str) { | |
return ('0'+ str).slice(-2); | |
}; | |
var dateLocal = function() { | |
var d = new Date(); | |
var s = d.getFullYear() + '-'; | |
s += zeroPad(d.getMonth()) + '-'; | |
s += zeroPad(d.getDate()) + 'T'; | |
s += zeroPad(d.getHours()) + ':'; | |
s += zeroPad(d.getMinutes()) + ':'; | |
s += zeroPad(d.getSeconds()); | |
return s; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment