Created
February 25, 2018 19:26
-
-
Save poloey/cbec3898bb0941605ed16375c64fdfae to your computer and use it in GitHub Desktop.
mysql_date_format_from_javascript
This file contains hidden or 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 str_pad(n) { | |
return String("00" + n).slice(-2); | |
} | |
var dateObj = new Date(); | |
var month = str_pad( dateObj.getUTCMonth() + 1); | |
var day = str_pad(dateObj.getUTCDate() + 1); | |
var year = dateObj.getUTCFullYear(); | |
newdate = year + "-" + month + "-" + day; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment