Created
June 2, 2014 03:02
-
-
Save joseluisq/0a08b83df0876c78e396 to your computer and use it in GitHub Desktop.
Convert string datetime to Javascript Date object
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
/** | |
* Convert string datetime to Javascript Date object | |
* Eg. "2014-04-23 22:06:17".toDateFromDatetime() | |
*/ | |
String.prototype.toDateFromDatetime = function() { | |
var parts = this.split(/[- :]/); | |
return new Date(parts[0], parts[1] - 1, parts[2], parts[3], parts[4], parts[5]); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment