var now = new Date(); //當前日期 var nowMonth = now.getMonth(); //當前月 var nowYear = now.getFullYear(); //當前年 //本月的開始時間 var monthStartDate = new Date(nowYear, nowMonth, 1); //本月的結束時間 var monthEndDate = new Date(nowYear, nowMonth+1, 0); var timeStar=Date.parse(monthStartDate)/1000;//s var timeEnd=Date.parse(monthEndDate)/1000;//s
注意:js是精確毫秒的,php是精確到秒的php