note 57767 added to function.checkdate
| From: | jmdoren at ok dot cl | Date: | Thu, 13 Oct 2005 16:50:27 +0000 |
| Subject: | note 57767 added to function.checkdate | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-96969@lists.php.net to get a copy of this message | ||
Here an example of use for checkdate, a function that returns the last day of a month
It uses checkdate to validate the number of days on february
<?php
function last_day( $mes, $ano=FALSE ){
/* ******************************* */
static $lasts = array( FALSE,31,28,31,30,31,30,31,31,30,31,30,31 );
if ( $mes <1 || $mes >12 )
{
return( FALSE );
}
if ( $mes == 2 ) // Febrero
{
if ( $ano == FALSE )
{
return( FALSE );
}
if ( checkdate ( 2, 29, $ano ) )
{
return ( 29 );
}
return( 28 );
}
return( $lasts[ $mes ] );
}
?>
I hope it is usefull for you
J M Doren
----
Manual Page -- http://www.php.net/manual/en/function.checkdate.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+57767
Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+57767&report=yes&reason=added+to+the+manual
Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+57767&report=yes&reason=bad+code
Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+57767&report=yes&reason=spam
Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+57767&report=yes&reason=useless
Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+57767&report=yes&reason=non-english
Delete: already in docs -- http://master.php.net/manage/user-notes.php?action=delete+57767&report=yes&reason=already+in+docs
Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+57767&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+57767&report=yes
Search -- http://master.php.net/manage/user-notes.php