Last active
December 31, 2018 04:06
-
-
Save xbalaji/f56d5cc8a10b516695c0e29394fa5ecc to your computer and use it in GitHub Desktop.
javascript to zero pad dates
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
<script> | |
var d = new Date(); | |
var mm = (d.getMonth() + 1).toString().padStart(2, "0"); | |
var dd = (d.getDate()).toString().padStart(2, "0"); | |
var yy = ((d.getFullYear() %100).toString()).padStart(2, "0"); | |
var date_str = '' + mm + '-' + dd + '-' + yy; | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment