Last active
May 25, 2017 15:33
-
-
Save viniciusdaniel/b3164f0b9a83a213fb5ed84eaf9b6632 to your computer and use it in GitHub Desktop.
Simple datetime timestamp patch for javascript
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
if (Date.prototype.toDateTime === undefined) { | |
Date.prototype.toDateTime = function() { | |
// simple left zero | |
var lz = function ( v ) { return v < 10 ? '0' + v : '' + v; }; | |
return this.getFullYear() + '/' + | |
lz( this.getMonth() + 1 ) + '/' + | |
lz( this.getDate() )+ ' ' + | |
lz( this.getHours() ) + ":" + | |
lz( this.getMinutes() ) + ":" + | |
lz( this.getSeconds() ); | |
}; | |
} | |
Author
viniciusdaniel
commented
May 25, 2017
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment