note 57767 deleted from function.checkdate by cece
| From: | cece@php.net | Date: | Tue, 15 Nov 2005 14:46:59 +0000 |
| Subject: | note 57767 deleted from function.checkdate by cece | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-98606@lists.php.net to get a copy of this message | ||
Note Submitter: jmdoren at ok dot cl
----
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