RE: [PHP] date HELP !!!!!

From: Date: Mon, 23 Jul 2001 14:38:57 +0000
Subject: RE: [PHP] date HELP !!!!!
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-59202@lists.php.net to get a copy of this message
I thought this might do it... if( date("d") == date("d",mktime (0,0,0,date("n"),0,0)) ){ echo "last day"; } But it doesn't seem to handle February in non leap years; ====8<========== $testMktimeArray = array( "7/23/2001", "1/1/2001", "12/31/2001", "2/28/1999", "2/29/1999", "2/28/1999", "2/29/1999", "2/28/2000", "2/29/2000", "2/28/2001", "2/29/2001", "2/28/2002", "2/29/2002", "2/28/2003", "2/29/2003", "2/28/2004", "2/29/2004", "2/28/2005", "2/29/2005", ); foreach( $testMktimeArray as $testDate){ list($m,$d,$y) = explode("/", $testDate); $testTime = mktime (0,0,0,$m,$d,$y); echo "test date \"$testDate\" is ".date("d M Y",$testTime); echo " month is ".date("n",$testTime); echo " End of month is ".date("d",mktime (0,0,0,date("n",$testTime)+1,0,0))."<br>"; if( date("d",$testTime) == date("d",mktime (0,0,0,date("n",$testTime)+1,0,0)) ){ echo "last day<br>"; } } echo "<br>"; ====8<========== Output; ====8<========== test date "7/23/2001" is 23 Jul 2001 month is 7 End of month is 31 test date "1/1/2001" is 01 Jan 2001 month is 1 End of month is 31 test date "12/31/2001" is 31 Dec 2001 month is 12 End of month is 31 last day test date "2/28/1999" is 28 Feb 1999 month is 2 End of month is 29 test date "2/29/1999" is 01 Mar 1999 month is 3 End of month is 31 test date "2/28/1999" is 28 Feb 1999 month is 2 End of month is 29 test date "2/29/1999" is 01 Mar 1999 month is 3 End of month is 31 test date "2/28/2000" is 28 Feb 2000 month is 2 End of month is 29 test date "2/29/2000" is 29 Feb 2000 month is 2 End of month is 29 last day test date "2/28/2001" is 28 Feb 2001 month is 2 End of month is 29 test date "2/29/2001" is 01 Mar 2001 month is 3 End of month is 31 test date "2/28/2002" is 28 Feb 2002 month is 2 End of month is 29 test date "2/29/2002" is 01 Mar 2002 month is 3 End of month is 31 test date "2/28/2003" is 28 Feb 2003 month is 2 End of month is 29 test date "2/29/2003" is 01 Mar 2003 month is 3 End of month is 31 test date "2/28/2004" is 28 Feb 2004 month is 2 End of month is 29 test date "2/29/2004" is 29 Feb 2004 month is 2 End of month is 29 last day test date "2/28/2005" is 28 Feb 2005 month is 2 End of month is 29 test date "2/29/2005" is 01 Mar 2005 month is 3 End of month is 31 ====8<========== > -----Original Message----- > From: Henrik Hansen [mailto:hh@mailserver.dk] > Sent: Monday, 23 July 2001 17:22 > To: php-general@lists.php.net > Subject: Re: [PHP] date HELP !!!!! > > > sjdtmv@tpg.com.au (Reductor) wrote: > > > $todaydate = date("m"); > > $tomorrowdate = date("m",time() + 86400); > > if($todaydate != $tomorrowdate){ > > echo "Tomorrow is a new month"; > >} > > or > > if (date("d") == date("j")) > echo "last day"; > > or something else :) > > > > ----- Original Message ----- > > From: Yamin Prabudy <phplist@pro.net.id> > > To: <php-general@lists.php.net> > > Sent: Monday, July 23, 2001 5:27 PM > > Subject: [PHP] date HELP !!!!! > > > >> hi, > >> how do i check that the current date is the end of month > >> > >> Thanks in Advance

« previous php.general (#59202) next »