Skip to content

Instantly share code, notes, and snippets.

@devm33
Created March 9, 2014 09:27
Show Gist options
  • Save devm33/9445131 to your computer and use it in GitHub Desktop.
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.
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