獲取當前時間 年月日時分秒
阿新 • • 發佈:2021-07-01
var date = new Date(); var seperator1 = "-"; var year = date.getFullYear(); var month = date.getMonth() + 1; var hour = date.getHours(); var minutes = date.getMinutes(); var seconds = date.getSeconds(); var strDate = date.getDate(); if (month >= 1 && month <= 9) { month = "0" + month; } if (strDate >= 0 && strDate <= 9) { strDate = "0" + strDate; } if (hour >= 0 && hour <= 9) { hour = "0" + hour; } if (minutes >= 0 && minutes <= 9) { minutes = "0" + minutes; }if (seconds >= 0 && seconds <= 9) { seconds = "0" + seconds; } var curtimestart = year + seperator1 + month + seperator1 + strDate + " " + '00' + ":" + '00' + ":" + '00'; var curtimeend = year + seperator1 + month + seperator1 + strDate + " " + hour + ":" + minutes + ":" + seconds;
轉載於:https://www.cnblogs.com/xzybk/p/11547354.html