note 52456 deleted from function.date by aidan
| From: | aidan@php.net | Date: | Sun, 31 Jul 2005 12:35:17 +0000 |
| Subject: | note 52456 deleted from function.date by aidan | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-92824@lists.php.net to get a copy of this message | ||
Note Submitter: development at lab-9 dot com
----
this function above takes date in format of YYYY-MM-DD (ex.: 2005-12-31) and checks, if this date is
in the calendar
the first function just checks, if february has 29 or 28 days in the requested year.
<?php
function schaltjahr($jahr)
{
if($jahr % 400 == 0)
{ return true; }
else if($jahr % 4 == 0 && $jahr % 100 != 0)
{ return true; }
else
{ return false; }
}
function validate_date($temp)
{
$temp = explode('-', $temp);
if(is_numeric($temp[0]))
{
if($temp[0] >= 1950)
{
if(is_numeric($temp[1]) && $temp[1] >= 1 && $temp[1] <= 12)
{
if(is_numeric($temp[2]) && $temp[2] >= 1)
{
if($temp[1] == 2)
{
// schaltjahr überprüfen
$schaltjahr_days=28;
if(schaltjahr($temp[0]))
{ $schaltjahr_days = 29; }
if($temp[2] <= $schaltjahr_days)
{
return true;
}
}
else
{
if($temp[1] >= 8)
{ $temp[1]++; }
if($temp[1] % 2 == 1)
{
if($temp[2] <= 31 && $temp[2] >= 1)
{
return true;
}
}
else if($temp[1] % 2 == 0)
{
if($temp[2] <= 30 && $temp[2] >= 1)
{
return true;
}
}
}
}
}
}
}
return false;
}
?>