如何显示小时数范围 [英] How to display range of hours

查看:71
本文介绍了如何显示小时数范围的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个数据库表,以时间格式存储餐厅营业时间作为时间范围.例如,如果餐厅的开放时间是上午9点至下午5点",则将有两列小时开放"和小时关闭",我将9:00存储在小时开放"中,将17:00存储在小时关闭"中.我需要做的是显示时间范围,例如:9:30 am 10:00 am 10:30 am 11:00 am 11:30 am直到5:00 pm

I have a database table storing opening hours of a restaurant as a time range in TIME format. Eg if the restaurant's opening hours are '9am-5pm', there will be 2 columns 'hours_open' and 'hours_close' where I store 9:00 in 'hours_open' and 17:00 in 'hours_close'. What I need to do is to display the range of hours eg: 9:30am 10:00am 10:30am 11:00am 11:30am until 5:00pm

有人能指出我正确的方向吗?

can anyone point me in the right direction?

推荐答案

$start = strtotime('6:00am');
$end = strtotime('09:00am');
$range = array();
while ($start !== $end)
{
    $start = strtotime('+30 minutes',$start);
    $range[] = date('h:ia', $start);
}
print_r($range);

这篇关于如何显示小时数范围的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆