-
-
Save wolf432/da3f67d218d5055f56efd3a6233b5fc6 to your computer and use it in GitHub Desktop.
JS获取当前世界
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
function CurentTime() | |
{ | |
var now = new Date(); | |
var year = now.getFullYear(); //年 | |
var month = now.getMonth() + 1; //月 | |
var day = now.getDate(); //日 | |
var hh = now.getHours(); //时 | |
var mm = now.getMinutes(); //分 | |
var ss = now.getSeconds(); //秒 | |
var clock = year + "-"; | |
if(month < 10) | |
clock += "0"; | |
clock += month + "-"; | |
if(day < 10) | |
clock += "0"; | |
clock += day + " "; | |
if(hh < 10) | |
clock += "0"; | |
clock += hh + ":"; | |
if (mm < 10) clock += '0'; | |
clock += mm + ":"; | |
if (ss < 10) clock += '0'; | |
clock += ss; | |
return(clock); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment