graham23s Posted August 27, 2007 Share Posted August 27, 2007 Hi Guys, i can't seem to get this what im trying to do is work out the elapsed time in DAYS from 2 dates code is: $time_now = time(); $d2 = date('Y-m-d H:i:s', $time_now); $d1 = date('Y-m-d H:i:s', strtotime($ng_date)); $days = ceil(($d1 - $d2) / (60 * 60 * 24)); when echoing out it produces: 2007-06-02 16:53:24 2007-08-27 18:00:51 which is right, but $days echoes out as 0. can anyone help lol cheers Graham Quote Link to comment https://forums.phpfreaks.com/topic/66912-solved-days-calculation/ Share on other sites More sharing options...
Barand Posted August 27, 2007 Share Posted August 27, 2007 d1 and d2 are date strings. You need to work with the seconds values $d2 = $time_now; $d1 = strtotime($ng_date); $days = ceil(($d1 - $d2) / (60 * 60 * 24)); Quote Link to comment https://forums.phpfreaks.com/topic/66912-solved-days-calculation/#findComment-335475 Share on other sites More sharing options...
graham23s Posted August 27, 2007 Author Share Posted August 27, 2007 Thanks again barry. Graham Quote Link to comment https://forums.phpfreaks.com/topic/66912-solved-days-calculation/#findComment-335489 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.