我正在尝试拆分包含时间的字符串,如“23:25:00”
我希望得到几小时和几分钟,但它会产生错误,如偏移......
我试过了:
$time= "12:12:50";
$time = explode(":", $time);
echo $time[0]; // Hours
echo $time[1]; // minutes
答案 0 :(得分:1)
$time = '12:23:59';
$timeParts = explode(':', $time);
echo $timeParts[0] . ': hours';
echo $timeParts[1] . ': minutes';
echo $timeParts[2] . ': seconds';