MrVaux76 Posted May 17, 2015 Share Posted May 17, 2015 Hi there Hope someone can help me with this, since I am really stuck.I have these 2 variables:$end$durationBoth of these comes in a HH:MM:SS format (24 hour clock)I need to subtract the $duration from the $end so I get the $start.I am getting all kind of weird results, even negative results.Example:$end = 22:10:25$duration = 37:45:28 (I know the days are changing here, but I have no interest in displaying that.)The $start should then be calculated to 08:24:57 - That I can´t get to Work Anyone who knows how to do this? Link to comment https://forums.phpfreaks.com/topic/296369-calculating-with-time-subtract/ Share on other sites More sharing options...
CroNiX Posted May 17, 2015 Share Posted May 17, 2015 What have you tried? Have you tried using the DateTime interface? http://php.net/manual/en/class.datetime.php Link to comment https://forums.phpfreaks.com/topic/296369-calculating-with-time-subtract/#findComment-1512105 Share on other sites More sharing options...
grissom Posted May 18, 2015 Share Posted May 18, 2015 Try this http://php.net/manual/en/datetime.sub.php but be careful if you are subtracting time around the switchover of daylight saving and read the notes on the page carefully. Good luck ! Link to comment https://forums.phpfreaks.com/topic/296369-calculating-with-time-subtract/#findComment-1512159 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.