Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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