Created
November 9, 2015 15:36
-
-
Save hxgdzyuyi/ca20f381b48096588c62 to your computer and use it in GitHub Desktop.
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
define(function() { | |
if (Date.prototype.toISOString) { | |
return function() { | |
return (new Date()).toISOString() | |
} | |
} | |
// modify from http://stackoverflow.com/a/8563517 | |
function pad(number) { | |
var r = String(number) | |
if ( r.length === 1 ) { | |
r = '0' + r | |
} | |
return r | |
} | |
return function() { | |
var date = new Date() | |
return date.getUTCFullYear() | |
+ '-' + pad( date.getUTCMonth() + 1 ) | |
+ '-' + pad( date.getUTCDate() ) | |
+ 'T' + pad( date.getUTCHours() ) | |
+ ':' + pad( date.getUTCMinutes() ) | |
+ ':' + pad( date.getUTCSeconds() ) | |
+ '.' + String( (date.getUTCMilliseconds()/1000).toFixed(3) ) | |
.slice( 2, 5 ) | |
+ 'Z' | |
} | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment