note 52456 added to function.date

From: Date: Mon, 02 May 2005 11:24:10 +0000
Subject: note 52456 added to function.date
Groups: php.notes 
Request: Send a blank email to php-notes+get-88858@lists.php.net to get a copy of this message
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; } ?> ---- Manual Page -- http://www.php.net/manual/en/function.date.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+52456 Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+52456&report=yes&reason=added+to+the+manual Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+52456&report=yes&reason=bad+code Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+52456&report=yes&reason=spam Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+52456&report=yes&reason=useless Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+52456&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+52456&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#88858) next »