Re: Date Error

From: Date: Sun, 19 Nov 2000 06:02:12 +0000
Subject: Re: Date Error
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-26104@lists.php.net to get a copy of this message
I found the same problems. For your specific case, you can use date ("t"); to get the number of days in the current month. I found that in general, using 0 or negative numbers to do date arithmetic with mktime() gave incorrect results, but this is an OSX specific issue. Additions seemed to be OK. HTH, Julian on 11/18/00 9:54 PM, Lon Baker at lon@mojomonkey.com wrote: > > The following code using PHP 4.02, Apache 1.3.14, Mac OS X PB: > > <?php > for ($i = 1990; $i <= 2010; $i++) { > $lastday = mktime (0,0,0,12,0,$i); > echo "Last day in Nov $i is: " . date("M d", $lastday) . > "<br>"; > } > ?> > > Produces the following incorrect output: > > Last day in Nov 1990 is: Nov 30 > Last day in Nov 1991 is: Nov 30 > Last day in Nov 1992 is: Nov 29 > Last day in Nov 1993 is: Dec 01 > Last day in Nov 1994 is: Nov 30 > Last day in Nov 1995 is: Nov 30 > Last day in Nov 1996 is: Nov 29 > Last day in Nov 1997 is: Dec 01 > Last day in Nov 1998 is: Nov 30 > Last day in Nov 1999 is: Nov 30 > Last day in Nov 2000 is: Nov 29 > Last day in Nov 2001 is: Dec 01 > Last day in Nov 2002 is: Nov 30 > Last day in Nov 2003 is: Nov 30 > Last day in Nov 2004 is: Nov 29 > Last day in Nov 2005 is: Dec 01 > Last day in Nov 2006 is: Nov 30 > Last day in Nov 2007 is: Nov 30 > Last day in Nov 2008 is: Nov 29 > Last day in Nov 2009 is: Dec 01 > Last day in Nov 2010 is: Nov 30 > > While the same code on PHP 3.016 produces correct output. Any ideas or > workarounds? >

« previous php.general (#26104) next »