但注意的是取得的是目前clinet端瀏覽器的時間喔非server上的時間要注意就好
var d = new Date(); var month = d.getMonth() + 1; var day = d.getDate(); var hour = d.getHours(); var minutes = d.getMinutes(); var seconds = d.getSeconds(); var NowDate = d.getFullYear() + '-' + toTen(month) + '-' + toTen(day); var Now = d.getFullYear() + '-' + toTen(month) + '-' + toTen(day) + ' ' + toTen(hour) + ":" + toTen(minutes)+":" +toTen(seconds); alert(NowDate); alert(Now); function toTen(s) { return s < 10 ? '0' + s : s; }