我寫了按周,用戶可以選擇去顯示日曆星期的腳本一次返回或轉發一週。除了每年的第一週仍然顯示錯誤的一年,12月31日顯示爲02/01,一切都很好。看來,只有第1周受到影響,日子又是正確的一週起
<?
if(isset($_POST['add_week'])){
$last_week_ts = strtotime($_POST['last_week']);
$display_week_ts = $last_week_ts + (3600 * 24 * 7);
} else if (isset($_POST['back_week'])) {
$last_week_ts = strtotime($_POST['last_week']);
$display_week_ts = $last_week_ts - (3600 * 24 * 7);
} else {
$display_week_ts = floor(time()/(3600 * 24)) * 3600 * 24;
}
$week_start = date('d-m-Y', $display_week_ts);
$week_number = date("W", $display_week_ts);
$year = date("Y", $display_week_ts);
echo $week_start.' '.$week_number.' '.$year;
?>
<table name="week">
<tr>
<?
for($day=1; $day<=7; $day++)
{
echo '<td>';
echo date('d-m-Y', strtotime($year."W".$week_number.$day))." | \n";
echo '</td>';
}
?>
</tr>
<tr>
<form name="move_weeks" method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
<input type="hidden" name="last_week" value="<? echo $week_start; ?>" />
<td colspan="7"><input type="submit" name="back_week" value="back_week" /><input type="submit" name="add_week" value="add_week" />
</td>
</form>
</tr>
</table>
任何幫助將不勝感激
你指的是哪一行?你應該真的保持你以前提出的問題,而不是開一個新的問題。您也沒有像原始問題中所建議的那樣更改循環中的回顯部分。 –
對不起,我從來沒有看到下面的代碼。感謝您的幫助 – tatty27