如果我的时间是上午12:00,并且我想显示为
11:30 pm 11:45 pm 12:00 am 12:15 am 12:30 am 请帮助我立即获取此iam学习
$i= $_GET['time']
$start=strtotime($i);
$end=strtotime('2:30');
for ($i=$start;$i<=$end;$i = $i + 15*60) {
echo date('H:i A',$i).'<br>';
}
获取结果为
00:00 AM
00:15 AM
00:30 AM
00:45 AM
01:00 AM
01:15 AM
01:30 AM
01:45 AM
02:00 AM
02:15 AM
02:30 AM
答案 0 :(得分:0)
答案 1 :(得分:0)
请尝试
<?php
$i= '12:00 am';
$start=strtotime("-30 minutes" , strtotime($i));
$end=strtotime("+30 minutes" , strtotime($i));
for ($i=$start;$i<=$end;$i = $i + 15*60)
{
echo "<br/>";
echo date('h:i A',$i).'<br>';
}
?>
答案 2 :(得分:-1)
<?php
$time_interval = $time->reservation_time_interval; //if 15 min
$dateTime = new DateTime($_GET['date'].$_GET['time']); //if 12:00 am
$dateTime->modify("-$time_interval min");
$date_pre= $dateTime->format('Y-m-d');
$time_pre= $dateTime->format('h:i a');
$dateTime = new DateTime($time_pre);
$dateTime->modify("-$time_interval min");
$time_pre1= $dateTime->format('h:i a');
$dateTime = new DateTime($_GET['time']);
$dateTime->modify("$time_interval min");
$time_post= $dateTime->format('h:i a');
$dateTime = new DateTime($time_post);
$dateTime->modify("$time_interval min");
$time_post1= $dateTime->format('h:i a');
echo $time_pre;echo $time_pre1;echo $time_post;echo $time_post;
?>
当您打印时,您会得到这个= 11:30 pm 11:45 pm 12:15 am 12:30 am