Ron Piggott wrote:
Where $date_reference is 2009-04-18 the following code gives me a day of
1969-12-30. How do I get it to be 2009-04-17? $previous_date = strtotime("-1 days", $date_reference); $previous_date = date('Y-m-d', $previous_date);


echo $previous_date;   outputs 1969-12-30

Ron



You need to read the strtotime page in the manual.

http://php.net/strtotime

It says that the second argument of the strtotime function is suppose to be a 
unix time stamp.

Is the value that you gave us for $date_reference a unix time stamp?  No

Your code should be like this.

// This converts 2009-04-19 00:00:00 into 1240099200
$date_reference_unix = strtotime($date_reference);
$previous_date = strtotime("-1 days", $date_reference_unix);
$previous_date = date('Y-m-d', $previous_date);

echo $previous_date;   outputs 1969-12-30


--
Jim Lucas

   "Some men are born to greatness, some achieve greatness,
       and some have greatness thrust upon them."

Twelfth Night, Act II, Scene V
    by William Shakespeare

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to