RE: [PHP] Date Manipulation

From: Date: Wed, 01 Dec 2004 20:59:22 +0000
Subject: RE: [PHP] Date Manipulation
Groups: php.general 
Request: Send a blank email to php-general+get-203265@lists.php.net to get a copy of this message
As was already mentioned, mktime() and strtotime() both return a serial date. I use mktime() a lot to add/subtract days and such. It automatically compensates for leap days and all that. Example: <?php $month = 1; $day = 31; $year = 2004; $serialdate = mktime(0,0,0,$month,$day + 1,$year); echo date("m/d/Y", $serialdate); ?> This should output "2/1/2004" (unless I made a typo). The initial 0,0,0 are the hour, minute, second. It works equally well with any numbers you give it for any of those values and if you throw it back into the date() function, you can format the outputted date however you want. I know mktime and strtotime were already mentioned, but I think examples help too so pardon me for expanding on it. -TG > -----Original Message----- > From: Christopher Weaver [mailto:booktues@yahoo.com] > Sent: Tuesday, November 30, 2004 9:19 PM > To: php-general@lists.php.net > Subject: [PHP] Date Manipulation > > > I've looked at the date functions in the manual but can't > find what I need. > All I want to do is add and subtract days without ending up > with bogus date > values. IOW, Nov. 29 + 7 days shouldn't be Nov. 36. > > Just a nod in the write direction would be great. > > Thanks. > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > >

« previous php.general (#203265) next »