virtuexru Posted October 29, 2008 Share Posted October 29, 2008 OK. Quick dilemma here. I have two dates. One is when a vehicle is "added" and one when it should be "deleted". So it would look like this: Added date: 2008-10-29 Deleted date: 2008-11-03 So I'm trying to do a psuedo "deleted - added = days left" but it doesn't work like that obviously. Should I strip the "-" and try subtraction? But that won't always be accurate. What do you guys suggest? Quote Link to comment https://forums.phpfreaks.com/topic/130613-subtracting-dates-to-get-days-left/ Share on other sites More sharing options...
virtuexru Posted October 29, 2008 Author Share Posted October 29, 2008 Nevermind, figured it out: $added = strtotime($row['_added']); $launch = strtotime($row['_launch']); // show the date it goes off in a readable format $dateoff = date('M d, Y', strtotime($row['_launch'])); $left = ($launch - $added); // rounds it to days instead of seconds $left = round($left / 86400); Quote Link to comment https://forums.phpfreaks.com/topic/130613-subtracting-dates-to-get-days-left/#findComment-677644 Share on other sites More sharing options...
PFMaBiSmAd Posted October 29, 2008 Share Posted October 29, 2008 http://dev.mysql.com/doc/refman/5.0/en/date-and-time-functions.html#function_datediff Quote Link to comment https://forums.phpfreaks.com/topic/130613-subtracting-dates-to-get-days-left/#findComment-677655 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.