希望有人可以告訴我這個小小的調試腳本是怎麼回事。PHP日期/時間和mktime
<?PHP
// function generates the list of times for
function generateTimes($date) {
$currentDate = $date;
echo "RECEIVED CURRENT DATE: " . date("m/d/Y g:iA", $currentDate) . "<br /><br />";
for($i = 0; $i < 48; $i++) {
echo date("g:iA", $currentDate) . "<br />";
$currentDate = mktime(date("g", $currentDate),date("i", $currentDate)+30,0,date("m", $currentDate),date("d", $currentDate),date("Y", $currentDate)); // 30 minutes
}
}
if (isset($_POST['generate_date'])) {
echo "Date Stamp: " . strtotime($_POST['date']) . "<br /><br />";
echo "The time you entered: " . date("r", strtotime($_POST['date'])) . "<br /><br />";
generateTimes($_POST['date']);
}
echo "<form method=post action='timestampgen.php'>";
echo "<input type=text name='date' />";
echo "<input type=submit name='generate_date' value='Generate Time Stamp' />";
echo "</form><br /><br />";
?>
我提交的日期,如10年10月1日上午12:00,我希望它產生的時間以30個分鐘間隔..但它似乎是工作,我認爲這是關係到我的mktime參數
我一直在工作一整天,所以這可能是我瘋了。
您忘了提及期望的輸出與實際輸出的不同。 – Matthew 2010-10-01 20:03:34