LLeoun Posted February 25, 2010 Share Posted February 25, 2010 Hi all, I'm doing some maths with the date: I want to add 9000 seconds to the date 2010-02-13T06:00:00+01:00 So I do a mktime timestamp with the date and I add the 9000 seconds (it's all seconds, isn't it?) But when I turn the addition's result back into date format, the 9000 seconds (2 hours and a half) are wrongly added. What am I doing wrong?? Thanks a lot! <?php $beginTime= "2010-02-13T06:00:00+01:00"; $duration= 9000; $r = substr($beginTime, 0, 19); $year= substr($r,0,4); $month = substr($r,5,2); $day = substr($r,8,2); $hour= substr($r,11,2); $minute = substr($r,14,2); $second = substr($r,17,2); echo"<br>"; echo $beginTime; echo" is the date in the beginning, and this is the duration: ";echo $duration; echo"<br>"; $beginTimeStamp = mktime($hour, $minute, $second, $month, $day, $year); $endTimeStamp = $beginTimeStamp + $duration; echo $beginTimeStamp;echo" + duration = ";echo $endTimeStamp;echo" which is the date: ";echo date("Ymd-h:m:s",$endTimeStamp); ?> Quote Link to comment Share on other sites More sharing options...
schilly Posted February 25, 2010 Share Posted February 25, 2010 code looks ok. what's the results you are getting? Quote Link to comment Share on other sites More sharing options...
LLeoun Posted February 26, 2010 Author Share Posted February 26, 2010 Oops, typo! Instead of echo date("Ymd-h:m:s",$endTimeStamp); has to be: echo date("Ymd-H:i:s",$endTimeStamp); Thanks a lot for reading! Quote Link to comment 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.