使用php添加两个类似格式的时间值 [英] adding two time values of similar formats using php
本文介绍了使用php添加两个类似格式的时间值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有两个时间值,如下所示
i have two time values as give below
$time = 06:58:00;
$time2 = 00:40:00;
我正在做这个计算特定用户的约会和可用时间
所以我尝试以这种方式
I am doing this for calculating the appointments and available time for a particular user so i tried in this way
$max_date=abs(strtotime($time) + strtotime($time2));
但是它返回$ max_date = 2673452280
任何建议pls
but it is returning $max_date =2673452280 any suggestions pls
推荐答案
此代码示例将在 $ time
中花费一小时,并将小时添加到 $ time2
给它
this code sample would take hour in $time
and add the hour in $time2
to it
例如:time = 06:58:00,time2 = 00:40:00,result = 07 :38:00
for example: time=06:58:00, time2=00:40:00, result = 07:38:00
$time = "06:58:00";
$time2 = "00:40:00";
$secs = strtotime($time2)-strtotime("00:00:00");
$result = date("H:i:s",strtotime($time)+$secs);
这篇关于使用php添加两个类似格式的时间值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文