note 16317 added to ref.datetime

From: Date: Wed, 24 Oct 2001 18:20:59 +0000
Subject: note 16317 added to ref.datetime
Groups: php.notes 
Request: Send a blank email to php-notes+get-19385@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 -- http://www.php.net/manual/en/ref.datetime.php http://master.php.net/manage/user-notes.php?action=edit+16317 http://master.php.net/manage/user-notes.php?action=delete+16317 http://master.php.net/manage/user-notes.php?action=reject+16317

« previous php.notes (#19385) next »