Iam having variable with value 9:30 am - 12:00 pm i.e
$val=$shift (o/p 9:30 am - 12:00pm)
I want to convert it to 09:30 am - 12:00pm, i mean i need to add 0 infront of number if time having one digit
收起
当前问题酬金
¥ 0 (可追加 ¥500)
支付方式
扫码支付
支付金额 15 元
提供问题酬金的用户不参与问题酬金结算和分配
支付即为同意 《付费问题酬金结算规则》
Assuming you are saving your time in your database as a string as 9:30 am - 12:00pm you can just split them. Then format each data.
9:30 am - 12:00pm
$val= "9:30 am - 12:00pm"; $splittedString = explode('-', $val); $time1 = date('h:ia',strtotime($splittedString[0])); $time2 = date('h:ia',strtotime($splittedString[1])); echo $time1." - ".$time2;
报告相同问题?
程序员都在用的中文IT技术交流社区
专业的中文 IT 技术社区,与千万技术人共成长
关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!