note 65221 added to function.strtotime

From: Date: Thu, 27 Apr 2006 02:45:41 +0000
Subject: note 65221 added to function.strtotime
Groups: php.notes 
Request: Send a blank email to php-notes+get-109811@lists.php.net to get a copy of this message
I wrote this function for my little project, it is responded to calculate the delivery date, and bah bah bah. function myDateFun($day) { if($day<0) { die("Error in function myDateFun(): the day range is from 0 to 10\n"); } $myWeekDay=array(0=>"Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday"); $today_week_day=date("w"); //weekday of today.... $prefix=""; if(($day+1)==$today_week_day) { $prefix=""; } else if(($day+1)<$today_week_day) { $prefix="last "; } else if(($day+1)>$today_week_day) { $prefix="next "; if(($day+1)>($today_week_day+5)) //next week's weekday after today's weekday.... { //example today is Wednesday, next Wednesday is today + 5 $prefix="+1 week ".$prefix; //(i.e Sat and Sun are not counted.), and next Thrusday is } //today + 6, in php strotime, the pramater should be } //"+1 week next Thrusday" $str=$prefix.$myWeekDay[$day]; return $date_time=date("Y-m-d",strtotime($str)); } for($i=0;i<10;i++) { echo myDateFun($i); } ---- Server IP: 202.181.244.117 Probable Submitter: 61.244.49.100 ---- X-Spam-Status: No, hits=3.1 required=5.0 tests=DATE_MISSING,FROM_NO_LOWER autolearn=no version=2.64 ---- Manual Page -- http://www.php.net/manual/en/function.strtotime.php Edit -- http://master.php.net/note/edit/65221 Del: integrated -- http://master.php.net/note/delete/65221/integrated Del: useless -- http://master.php.net/note/delete/65221/useless Del: bad code -- http://master.php.net/note/delete/65221/bad+code Del: spam -- http://master.php.net/note/delete/65221/spam Del: non-english -- http://master.php.net/note/delete/65221/non-english Del: in docs -- http://master.php.net/note/delete/65221/in+docs Del: other reasons-- http://master.php.net/note/delete/65221 Reject -- http://master.php.net/note/reject/65221 Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#109811) next »