MySQL Forums :: PHP :: Time remaining calculations

Advanced Search

Time remaining calculations
Posted by: Andrew Germishuys ()
Date: October 03, 2012 01:15PM

Good day all :)

I've been battling with a few calculations on dates / times, and have not made much headway with any of the hundreds of results I've visited from searching.

I'm working on a site where an item will be available for a certain amount of time (stored in the DB as days) from a creation date (stored as a timestamp). So, the expiry date would be creation date plus number of days.

What I am looking to do, is show time remaining, in days, hours, minutes, until the end of that 'expiry' day.

I have to use PHP 5.2, so am limited slightly there.

For days remaining, I've tried:
$VarDaysRemaining = round(abs(strtotime($VarCreateDate)-strtotime('+' . $VarCampaignLength . ' day', time()))/86400);

I did read that this gives an answer a day short.

Any pointers would be a great help.
Thank you in advance.

Options: ReplyQuote

Subject Written By Posted
Time remaining calculations Andrew Germishuys 10/03/2012 01:15PM
Re: Time remaining calculations Peter Brawley 10/04/2012 08:01AM

Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.