Last active
November 6, 2015 12:46
-
-
Save matthewdfuller/69eb1aa1e57d4b24254d to your computer and use it in GitHub Desktop.
Formats a JavaScript date with leading zeros
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
var date = new Date(); | |
var dateString = date.getFullYear() + '/' + ('0' + (date.getMonth()+1)).slice(-2) + '/' + ('0' + date.getDate()).slice(-2) + ' ' + ('0' + date.getHours()).slice(-2) + ':' + ('0' + date.getMinutes()).slice(-2) + ':' + ('0' + date.getSeconds()).slice(-2); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
good idea!