以下のコードは偉大な強さ、そして大晦日として考慮されるべき計画期間のケースを費やした週のコンピューティング、利用可能とプロのテストです。
。$( "#レポート")の変更(関数(){
VAR = $報告書(本).val();
VAR BEGINTIME = '';
VARたendTime = '';
VAR =新しい新MyDateに該当日付();
IF(報告書= = 'デイリー'){
//最後ゲット
myDate.setTime(myDate.getTime() - * 1000年* 3600 24);
BEGINTIME myDate.getFullYear =()+ " - " +(myDate.getMonth()+ 1)+ "。 - 「+ myDate.getDate();
endTimeは= BEGINTIME;
}他のIF(レポート== '週刊'){
//週の開始時刻と終了時刻を取得
するvar weekDate =新しい日付を(myDate.getTime( ) - 7 * 24 * * 1000 3600);開始時刻を//使用して計算される
のvar weekDate2 =新しいDate(myDate.getTime( ) - 7 * 24 * 1000年* 3600); 計算することにより、//終了時刻を
するvar日= weekDate.getDay();
VAR時間= weekDate.getDate() -日+(日=== 0 -6:1)。
するvarたstartDate =新しいDate(weekDate.setDate(時間));
開始時間= startDate.getFullYear()+ ' - ' +(startDate.getMonth()+ 1)+ ' - ' + startDate.getDate()。
VaRのendDateに=新しいDate(weekDate2.setDate(時間+ 6));
endTimeは= endDate.getFullYear()+ ' - ' +(endDate.getMonth()+ 1)+ ' - ' + endDate.getDate()。
}それ以外の場合(レポート== '毎月'){
//获取上一月的开始和结束时间
VAR年= myDate.getFullYear();
VAR月= myDate.getMonth();
(月=== 0){もし
月= 12。
年=年-1;
}他(月<10){もし
月= '0' +月;
VaRのmonthDate =新しい日付(年、月、0);
開始時間=年+ ' - ' +月+ ' - 01';
endTimeは=年+ ' - ' +月+ ' - ' + monthDate.getDate();
}それ以外の場合(レポート== '年間'){
//获取去年的开始和结束时间
VAR年= myDate.getFullYear() - 1;
開始時間=年+ ' - 01-01';
endTimeは=年+ ' - 12-31';
}
。$( "#のBEGINTIME")のval(開始時間)。
$( "#の終了時刻")のval(endTimeは)。
});