millercj Posted March 15, 2015 Share Posted March 15, 2015 I'm attempting to add time: $a = mktime(0, 0, 12); $b = mktime(0, 0, 5); echo date('h:i:s', $a + $b); My echo is reading "03:00:17" Where the heck is the 3 hours coming from? Quote Link to comment https://forums.phpfreaks.com/topic/295264-date-addition-error/ Share on other sites More sharing options...
Solution Ch0cu3r Posted March 15, 2015 Solution Share Posted March 15, 2015 (edited) Use strtotime or the DateTime object for adding time to an existing date. Adding two timestamps like that is not the correct way. Edited March 15, 2015 by Ch0cu3r Quote Link to comment https://forums.phpfreaks.com/topic/295264-date-addition-error/#findComment-1508158 Share on other sites More sharing options...
millercj Posted March 15, 2015 Author Share Posted March 15, 2015 Gottcha...thanks DateTime it is Quote Link to comment https://forums.phpfreaks.com/topic/295264-date-addition-error/#findComment-1508161 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.