note 16317 deleted from ref.datetime by jimw
| From: | jimw@php.net | Date: | Wed, 24 Oct 2001 20:45:51 +0000 |
| Subject: | note 16317 deleted from ref.datetime by jimw | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-19402@lists.php.net to get a copy of this message | ||
for all of the programmers out there who love to do things inefficient and much more slower but all
on their own.
the function below returns the next day
without any predefind date / time functions...
function nextDay($date) {
//YYYY-MM-DD
list($year,$month,$day) = explode("-",$date);
// check if newyear
if($month==12 AND $day==31) {
$year++;
return $year."-01-01";
// check if feb and if
} elseif($month=="02" AND $day=="28") {
if($year %4 == 0) {
$day++;
return $year."-".$month."-".$day;
} else {
$month++;
return $year."-".$month."-1";
}
} elseif($month=="02" AND $day==29) {
$month++;
return $year."-".$month."-1";
// check if 31 day or 30
} else {
if($month<8) { $flag=0; }
if($month>8) { $flag=1; }
if(($month % 2) == $flag) {
if($day == "30") {
$month++;
return ($year."-".$month."-01");
} else {
$day++;
return ($year."-".$month."-".$day);
}
} else {
if($day == "31") {
$month++;
return ($year."-".$month."-01");
} else {
$day++;
return ($year."-".$month."-".$day);
}
}
}
} // function nextday