On Sat, January 27, 2007 10:51 pm, Ron Piggott wrote:
> I have date in the variable $date_reference in the format YYYY-MM-DD.
> How do I find out the date before this and the date after this?  Ron

$date_reference = date('Y-m-d');
list($y, $m, $d) = explode('-', $date_reference);
//Let the computer figure out leap year and all that junk:
$yesterday = mktime(1, 0, 0, $m, $d - 1, $y);
$tomorrow = mktime(1, 0, 0, $m, $d + 1, $y);

The mktime function "knows" about months/years and leap years and all
that junk and will "wrap" the dates around to make this work out
correctly, no matter what day it is.

-- 
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some starving artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?

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

Reply via email to