I have a mysql datetime object, let's call it "purchase date", like so 2014-04-15 14:47:39.
I also have a mysql time object, let's call it "shelf life", like so 168:00:00, meaning that product has a shelf life of 168 hours, or seven days, after its purchase date. I would like to know how many days there are until this product expires, with the following formula (or something similar)
daysRemainingBeforeExpiring = [purchase_date (datetime) + shelf_life (time)] - now(datetime)
Please correct me if my formula is wrong, but I believe this should return the number of days before this item expires (or a negative number if it's expired). How can I perform this math operation on the datetime and time objects in PHP?