我正在尝试在 php 中更新 for 循环中的时间,但得到了意想不到的结果。
我试过使用 while 循环仍然相同的结果。不知道哪里出错了。
$time = strtotime(date('H:i'));
$trounds= 15;
for($j = 1; $j<= $trounds ; $j++){
echo $time += date("H:i:s", strtotime("+10 minutes", $time));
echo date('H:i:s',$time);
echo '</br>';
}
假设如果时间是 12:00 我需要输出像 12:10 12:20 12:30 等等。
我想,你不需要date()
和strtotime()
两次尝试像下面
$time = strtotime(date('4:i'));
$trounds= 15;
for($j = 1; $j<= $trounds ; $j++){
echo $time += 10*60;
echo ' : '.date('H:i:s',$time);
echo "\n";
}
输出 :
1563017220 : 04:27:00
1563017820 : 04:37:00
1563018420 : 04:47:00
1563019020 : 04:57:00
1563019620 : 05:07:00
1563020220 : 05:17:00
1563020820 : 05:27:00
1563021420 : 05:37:00
1563022020 : 05:47:00
1563022620 : 05:57:00
1563023220 : 06:07:00
1563023820 : 06:17:00
1563024420 : 06:27:00
1563025020 : 06:37:00
1563025620 : 06:47:00
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句