PHP累加时间,分钟,秒 [英] PHP Add Up Hours, Minutes, Seconds
本文介绍了PHP累加时间,分钟,秒的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
考虑到一系列的小时,分钟和秒(例如:01:30:00或00:30:00),我想将它们加起来并将其总和转换为秒.
Given a series of hours, minutes, and seconds (ex: 01:30:00 or 00:30:00), I would like to add up each and convert the sum to seconds.
例如,如果总时间为02:30:00,则总时间应以秒为单位.
For example, if the total time is 02:30:00, the total time should be in seconds.
谢谢!
推荐答案
$timestr = '00:30:00';
$parts = explode(':', $timestr);
$seconds = ($parts[0] * 60 * 60) + ($parts[1] * 60) + $parts[2];
这篇关于PHP累加时间,分钟,秒的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文