<?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 = "";
}
}
?>
解决方案 »
- zend studio 8.0如何查看数据库查询出的结果集
- 请教php发信功能
- 请问构造函数有没有返回值啊?
- 问一个高级问题:php是否可转换成机器语言(exe)
- 哥哥姐姐们~~~如何实现点击按钮(不提交,onclick事件),在javascript里面写修改表
- 我的Mysql罢工了。。。。。
- 怎么屏蔽文件的地址?
- 兄弟们帮忙,看看郁闷死了
- 初次用php,遇到问题,请帮忙指教
- php获取数组中相加和最接近或等于给定值的算法(类似01背包)
- php高手来帮忙,mysql输出表格问题,数据库中只有13条记录,我想输出5行5列共25条记录,差12条怎么补足?
- 請問怎樣才能用php顯示.swf flash檔呢?
你的程序运行10秒,第一个和最后一个就相差10秒。试试 $tm = mktime(date("H:i"));
$strStarttime = 15:00
你是打算每过一个整点就增加一分钟间隔时间吗?
$tm = $tm + $nexttime * 60;如果我在这里直接用 $tm=$tm+900; 的话 结果就没有任何问题
<?php
$strStarttime = "15:00";
for($i=0;$i<20;$i++)
{
$tm = strtotime($strStarttime);
$dt = date('H:i', $tm);
$tm = $tm + $strStarttime * 60;
$strStarttime=date('H:i',$tm);
echo $dt." ".$tm." ".$strStarttime." ".($strStarttime*60).PHP_EOL;
}
运行结果
15:00 1307949300 15:15 900
15:15 1307950200 15:30 900
15:30 1307951100 15:45 900
15:45 1307952000 16:00 960
16:00 1307952960 16:16 960
16:16 1307953920 16:32 960
16:32 1307954880 16:48 960
16:48 1307955840 17:04 1020
17:04 1307956860 17:21 1020
17:21 1307957880 17:38 1020
17:38 1307958900 17:55 1020
17:55 1307959920 18:12 1080
18:12 1307961000 18:30 1080
18:30 1307962080 18:48 1080
18:48 1307963160 19:06 1140
19:06 1307964300 19:25 1140
19:25 1307965440 19:44 1140
19:44 1307966580 20:03 1200
20:03 1307967780 20:23 1200
20:23 1307968980 20:43 1200可以看每循环四次的时候 $strStarttime * 60 就会多60
所以往后都会出问题
<?php
$dtnext = "";
$dt = "";
$nexttime = "";
$tm = strtotime($strStarttime);
$tm = $tm + $strStarttime * 60; //这里是用15:00 乘以60 结果是900
//echo $tm."<br>\n";
//$dt = date('H:i', $tm);
for($j = 1; $j <= $strInquiryCount; $j++) {
if( $j == 1){
$dt = date('H:i', $tm); //这里dt是15:15
$nexttime = $dt; //nexttime是 15:15
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; //你这里用15:15 乘 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 = "";
}
}
?>