我用的簡單的直接的字元串格式轉化 ...
我用的簡單的直接的字元串格式轉化
function getTimeStr() { var date = new Date(); var year = date.getFullYear(); var month = date.getMonth() + 1; var day = date.getDate(); var hours = date.getHours(); var minutes = date.getMinutes(); if (month.length == 1) { month = "0" + month; } if (day.length == 1) { day = "0" + day; } if (hours.length == 1) { hours = "0" + hours; } if (minutes.length == 1) { minutes = "0" + minutes; } var d = year + "-" + month + "-" + day + " " + hours + ":" + minutes; return d; }