Page 2 of 2

Re: Get Date, add 7 days, convert date to m:dd:yy - how?

Posted: Thu Jan 26, 2012 7:28 am
by simonmlewis
Hi
Can someone help me further with this please?

I'm trying to convert some calculations of dates, into an actual figure of 'days'.

Code: Select all

$todaydate = date('Y-m-d');
$dateenduse = strtotime($row->datepricedrop);
$dateendwarning = new DateTime($row->datepricedrop);
$minus5 = date('Y-m-d', strtotime("-5 days", $dateenduse));
$remaining = ($minus5);
I'm stuck on the $remaning part, and then on how to convert.

A date is set.
I need to warn the administrator when that date is approaching, starting from 5 days away.
For instance: Date set is 2012-01-30
I want to warn the administrator when it is 26th, 27th....etc.
The only way I see to do thia, is to calculate "-5 days" from the $row->datepricedrop.

If the date has arrived, I set an icon to black.
If it is outside of the 5 days, ie, just been set, it shows red.
But for a 5 days warning, I am showing orange (or perhaps grey).

How do I get that remaining figure as a "number of days" please?