PHP碰到一个怪问题,做一个排班表的时候,循环显示时间的时候到第五个就多加了一秒!!!!怪
PHP code
<?php $dtnext = ""; $dt = ""; $nexttime = ""; $tm = strtotime($strStarttime); $tm = $tm + $strStarttime * 60; //echo $tm."<br>\n"; //$dt = date('H:i', $tm); for($j = 1; $j <= $strInquiryCount; $j++) { if( $j == 1){ $dt = date('H:i', $tm); $nexttime = $dt; echo "<tr width=\"238\">\n\r<td width=\"238\">".$strStarttimeTmp."-".$dt."</td>\n\r<td width=\"238\">预约</td>\n\r<td width=\"238\">预约</td>\n\r<td width=\"238\">预约</td>\n\r<td width=\"238\">预约</td>\n\r<td width=\"238\">预约</td>\n\r<td width=\"238\">预约</td>\n\r<td width=\"238\">预约</td>\n\r</tr>"; }else{ echo "<br>".$j.":".$nexttime."<br>"; $tm = strtotime($nexttime); $tm = $tm + $nexttime * 60; //echo $tm."<br>\n"; $dtnext = date('H:i', $tm); echo $j."--".$nexttime."++".$tm."++".$dtnext."<br>\n"; echo "<tr width=\"238\">\n\r<td width=\"238\">".$nexttime."-".$dtnext."</td>\n\r<td width=\"238\">预约</td>\n\r<td width=\"238\">预约</td>\n\r<td width=\"238\">预约</td>\n\r<td width=\"238\">预约</td>\n\r<td width=\"238\">预约</td>\n\r<td width=\"238\">预约</td>\n\r<td width=\"238\">预约</td>\n\r</tr>"; $nexttime = $dtnext; $tm = ""; } } ?>
作者: wanhui1827 发布时间: 2011-06-11
$tm = strtotime($strStarttime); 是系统的当前时间。
你的程序运行10秒,第一个和最后一个就相差10秒。
试试 $tm = mktime(date("H:i"));
你的程序运行10秒,第一个和最后一个就相差10秒。
试试 $tm = mktime(date("H:i"));
作者: changjay 发布时间: 2011-06-12