我已经在PHP中使用了以下日期选择器作为时间表,但是当我使用它时,它从PHP时间开始(1970)开始。如何让它显示当前日期?
//date selector
$weekStart = 1;
$date = date('Y').'-'. date('m').'-'. date('d');
$timestamp = strtotime($date);
$dayOfWeek = date('N', $timestamp);
echo("<br><br><form action='' name='timetable' method='Post'><div style='position:relative;left:40%;'><h4>Select Week Beginning</h4></div><div style='float:middle;position:relative;left:39%;'><select onchange='submit();' name='date'>");
for ($i = 0; $i <= 10; $i++) {
$startDate = mktime(0,0,0, date('n', $timestamp), date('j', $timestamp) - $dayOfWeek + $weekStart + ( $i * 7), date('Y', $timestamp));
if(date('d-m-Y', $startDate) == $_POST['date']){
$selected = "selected='selected'";
}
else{
$selected = "";
};
echo("<option ".$selected." >". date('d-m-Y', $startDate)."</option>");
}
echo('</select></form></div><br>');
echo("<table style='border:1px solid;'>");
$weekStart = 0;
if(isset($_POST['date'])){
$timestamp = strtotime($_POST['date']);
}else{
$timestamp = strtotime($date);
};
for ($i = 1; $i <= 7; $i++) {
$dayrow = mktime(0,0,0, date('n', $timestamp), date('j', $timestamp) - $dayOfWeek + $weekStart + $i , date('Y', $timestamp));
echo("<td style='text-align:left;width:800px;margin-top:10px;margin-bottom:10px;padding-left:10px;'><h4>".date('D j-m-Y', $dayrow)."</h4></td>");
echo("<td >");
提前致谢