我使用以下方法将时间四舍五入为一分钟:
$mytime = mdate("H:i:s", $time_in_seconds);
$rounded_time = date('H:i:s', round(strtotime($mytime)/60)*60);
例如,输出为:来自未舍入01:08:34
的01:09:00
。
如何使用代码但保留秒格式而不是更改日期?
使用
$rounded_time = date('H:i:0');
?
我使用以下方法将时间四舍五入为一分钟:
$mytime = mdate("H:i:s", $time_in_seconds);
$rounded_time = date('H:i:s', round(strtotime($mytime)/60)*60);
例如,输出为:来自未舍入01:08:34
的01:09:00
。
如何使用代码但保留秒格式而不是更改日期?
使用
$rounded_time = date('H:i:0');
?