經常使用PHP mktime()的開發者在使用JavaScript new Date()的時候最常忘記的狀況就是 javascript的月份參數必須要 -1, 因為他的月份是從0開始代表1月份。


$year = 2018; $month = 05; $day = 31; $h = "09"; $i = "10"; $s = "00"; echo mktime($h,$i,$s,$month,$day,$year);

var year = 2018; var month = "05"; var day = 31; var h = "09"; var i = "10"; var s = "00"; console.log(new Date(year, month-1, day, h, i, s));

Leave a reply

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong> 

required