Re: DATE

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux