本文介绍了如何使用PHP减去两个时间值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我几乎完成了在互联网上找到的所有内容。过去两天我一直在努力,但无法得到满意的答案。我只想减去两次。例如22:00:00 - 00:30:00 = 21:30:00
我尝试了什么:
I have done almost everything I found on the internet. I have been trying for the past two days but couldn't get the desire answer. I just want to subtract two times. example 22:00:00 - 00:30:00 = 21:30:00
What I have tried:
$hourToEatLastMeal = strtotime('00:30:00');
$hourToEatWorkout = strtotime('01:30:00');
$hourBetweenMeal = strtotime('07:30:00');
$lastMealRequested = strtotime($row['lastMeal']); //22:00:00 //value getting from query.
$startEating = $lastMealRequested - $hourToEatLastMeal ;//21:30:00 (want this answer)
$timeToEat = $startEating- $hourBetweenMeal; //14:00:00 (want this answer)
$whenToWorkout = $timeToEat - $hourToEatWorkout; //12:30:00 (want this answer)
$whenToWorkout = date("H:i:s",($whenToWorkout));//12:30:00 (want this answer)
$timeToEat = date("H:i:s",($timeToEat));//14:00:00 (want this answer)
$startEating = date("H:i:s",($startEating));//21:30:00 (want this answer)
推荐答案
这篇关于如何使用PHP减去两个时间值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!