Bendude14 Posted August 11, 2008 Share Posted August 11, 2008 Can someone point me in the right direction for subtracting one date from another 11/08/2008 - 05/04/2008 = Number of days between these two dates? eg 128 days Quote Link to comment Share on other sites More sharing options...
bluejay002 Posted August 11, 2008 Share Posted August 11, 2008 If you are not to do it SQL, then you can do it by converting both dates to a timestamp, then deduct then convert into days. example: <?php $date1 = '2008-02-05'; $date2 = '2008-03-05'; $secsInDay = 60 * 60 * 24; $secsInterval = strtotime($date2) - strtotime($date1); $daysInterval = $secsInterval / $secsInDay; echo $daysInterval; ?> Quote Link to comment Share on other sites More sharing options...
Bendude14 Posted August 11, 2008 Author Share Posted August 11, 2008 Thanks for that i will give it a go. I do have SQL available if there is an easier way using the database? ben Quote Link to comment Share on other sites More sharing options...
bluejay002 Posted August 11, 2008 Share Posted August 11, 2008 definitely... and i do recommend it than using PHP for this kind of stuff. this is possible using DATEDIFF() example: ... DATEDIFF(field_date_one, field_date_two) ... the result will always be in days jay, Quote Link to comment Share on other sites More sharing options...
Bendude14 Posted August 11, 2008 Author Share Posted August 11, 2008 Thanks just what i needed Ben Quote Link to comment Share on other sites More sharing options...
bluejay002 Posted August 12, 2008 Share Posted August 12, 2008 your welcome 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.