Re: DATE

From: Date: Tue, 30 Jan 2007 00:11:13 +0000
Subject: Re: DATE
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-247977@lists.php.net to get a copy of this message
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?

« previous php.general (#247977) next »