note 48004 added to function.date
| From: | Mart�nGonz�lez at osu1 dot php dot net | Date: | Wed, 08 Dec 2004 21:49:28 +0000 |
| Subject: | note 48004 added to function.date | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-81547@lists.php.net to get a copy of this message | ||
<?
/*
ENGLISH [Inglés] (excuses for my english, it's not good):
This function allows you to know if the date of a year is real.
It determines leap years (February == 29). If the introduced values are correct will return TRUE,
else return FALSE
Good Luck (Y)
marting_dc(a)yahoo.com
ESPAÑOL [Spanish]:
Esta función te permite determinar si una fecha es correcta.
Determina años bisiestos (Febrero == 29), y los meses que terminan en 31 o los que no.
Si los valores introducidos son correctos el algoritmo devolverá TRUE, sino devolverá FALSE
Suerte (Y)
marting_dc(a)yahoo.com
*/
function determine($day,$month,$year) {
if ($month == 2 && $day > 28) {
$year = $year/4;
$year = number_format($year,2,'.','');
list($ent,$dec) = explode('.',$year);
if ($dec > 0 || $day > 29) {
$cmp = true;
}
} else {
if ($day == 31) {
if ($month == 4 || $month == 6 || $month == 9 ||$month == 11) {
$cmp = true;
}
}
}
if ($cmp == false) {
return true;
} else {
return false;
}
}
if (determine($day,$month,$year)) {
echo 'Fecha buena || The date is ok';
} else {
echo 'Fecha mala || Date wrong';
}
?>
----
Manual Page -- http://www.php.net/manual/en/function.date.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+48004
Delete -- http://master.php.net/manage/user-notes.php?action=delete+48004&report=yes
Reason: bad code -- http://master.php.net/manage/user-notes.php?action=delete+48004&report=yes&reason=bad+code
Reason: spam -- http://master.php.net/manage/user-notes.php?action=delete+48004&report=yes&reason=spam
Reason: useless example -- http://master.php.net/manage/user-notes.php?action=delete+48004&report=yes&reason=useless+example
Reason: contains commercial links -- http://master.php.net/manage/user-notes.php?action=delete+48004&report=yes&reason=contains+commercial+links
Reason: useless note -- http://master.php.net/manage/user-notes.php?action=delete+48004&report=yes&reason=useless+note
Reject -- http://master.php.net/manage/user-notes.php?action=reject+48004&report=yes
Search -- http://master.php.net/manage/user-notes.php