-
-
Save deostroll/5861be7974bb76a0f62bcf75ce3d8e9c to your computer and use it in GitHub Desktop.
javascript date formatting
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
var today = new Date(); | |
function fmtDate(today) { | |
return `${today.getFullYear()}${('0' + (today.getMonth() + 1)).slice(-2)}${('0' + today.getDate()).slice(-2)}-${('0' + today.getHours()).slice(-2)}_${('0' + today.getMinutes()).slice(-2)}_${('0' + today.getSeconds()).slice(-2)}`; | |
} | |
fmtDate(today); | |
//ex . Wed Aug 28 2013 17:50:28 GMT+0900 (KST) -> "20130828_17-50-28" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment