Created
August 22, 2011 14:16
-
-
Save adhipg/1162478 to your computer and use it in GitHub Desktop.
MySQL Date to JavaScript Date
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
function getJavaScriptDate(timestamp) { | |
var regex=/^([0-9]{2,4})-([0-1][0-9])-([0-3][0-9]) (?:([0-2][0-9]):([0-5][0-9]):([0-5][0-9]))?$/; | |
var parts=drink.post_date.replace(regex,"$1 $2 $3 $4 $5 $6").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