note 26118 added to ref.datetime

From: Date: Fri, 18 Oct 2002 15:17:48 +0000
Subject: note 26118 added to ref.datetime
Groups: php.notes 
Request: Send a blank email to php-notes+get-38254@lists.php.net to get a copy of this message
<?PHP //a simple script to create two separate dates: statement date and //due date-- useful for billing purposes. //set the needed variables $month = 10; $day = 18; $year=2002; $nperiod = 12; //set two separate array variables to store statement date //and due date respectively $newbday=array(); $newdday=array(); //format for timestamp $bday = mktime(0,0,0,$month, $day, $year); $dday = mktime(0,0,0,$month, $day, $year); //format for a readable date "MM/DD/YYYY" $bday = date("m/d/Y",$bday); $dday = date("m/d/Y",$dday); //loop thru until $i reaches 12 for($i=0;$i<$nperiod;$i++) { //get the date string and explode it into three separate variables list($month, $day, $year) = explode("/",$bday); list($month, $day, $year) = explode("/",$dday); //set the date to increment $bday = mktime(0,0,0,$month, $day+30, $year); $dday = mktime(0,0,0,$month, $day+30+5, $year); /*store the incremented date to the array variables defined earlier*/ $nbday = date("m/d/Y",$bday); $ndday = date("m/d/Y",$dday); $newbday = $nbday; $newdday = $ndday; //assign new values for $bday and $dday $bday = $newbday; $dday = $newdday; print ("Statement date :" .$bday. " Due date: " .$dday); print("<br />"); } ?> -- http://www.php.net/manual/en/ref.datetime.php http://master.php.net/manage/user-notes.php?action=edit+26118 http://master.php.net/manage/user-notes.php?action=delete+26118 http://master.php.net/manage/user-notes.php?action=reject+26118

« previous php.notes (#38254) next »