php-general | 2001072
Date: 07/23/01
- Next message: Mark Lo: "[PHP] crate mysql table command"
- Previous message: Adi Ciutureanu: "[PHP] ignore message - test"
- In reply to: Henrik Hansen: "Re: [PHP] date HELP !!!!!"
- Next in thread: Daniel Rezny: "Re: [PHP] date HELP !!!!!"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
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 <email protected>]
> Sent: Monday, 23 July 2001 17:22
> To: php-general <email protected>
> Subject: Re: [PHP] date HELP !!!!!
>
>
> sjdtmv <email protected> (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 <email protected>>
> > To: <php-general <email protected>>
> > 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
-- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: php-general-unsubscribe <email protected> For additional commands, e-mail: php-general-help <email protected> To contact the list administrators, e-mail: php-list-admin <email protected>
- Next message: Mark Lo: "[PHP] crate mysql table command"
- Previous message: Adi Ciutureanu: "[PHP] ignore message - test"
- In reply to: Henrik Hansen: "Re: [PHP] date HELP !!!!!"
- Next in thread: Daniel Rezny: "Re: [PHP] date HELP !!!!!"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]

