Created
November 2, 2021 06:14
-
-
Save wjx0912/9eb378e71ea85fccb3151b8eb5a19729 to your computer and use it in GitHub Desktop.
javascript print date&time (yyyy-mm-dd hh:mm:ss:SS)
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 getNowTime() { | |
var d = new Date; | |
var dformat = | |
[ | |
d.getFullYear(), | |
("00" + (d.getMonth()+1)).slice(-2), | |
("00" + d.getDate()).slice(-2) | |
].join('-') | |
+ ' ' | |
+ [ | |
("00" + d.getHours()).slice(-2), | |
("00" + d.getMinutes()).slice(-2), | |
("00" + d.getSeconds()).slice(-2), | |
("000" + d.getMilliseconds()).slice(-3) | |
].join(':'); | |
return dformat; | |
} | |
console.log(getNowTime()); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
output:
"2021-11-02 14:09:05:370"