note 80203 deleted from function.strtotime by felipe

From: Date: Sat, 05 Jan 2008 02:18:31 +0000
Subject: note 80203 deleted from function.strtotime by felipe
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-134806@lists.php.net to get a copy of this message
Note Submitter: ifoundthetao at gmail dot com ---- Here is a function for getting the timestamp from a date if you have mm/dd/yyyy formats. I saw similar functions, but this one does exactly what I need it to do with no hassle. <?php function format_date($m, $d, $y) { //check for Y2K38 Bug if($y>=2038) return null; //make sure that the months are valid if($m>12 || $m<1) return null; //default to the first of the month. if($d>31 || $d>1) $d = 1; //eliminate any leading 0's for the date if($m<10 && strlen($m)>1) $m=substr($m,-1); //create month array $month[1] = "January"; $month[2] = "February"; $month[3] = "March"; $month[4] = "April"; $month[5] = "May"; $month[6] = "June"; $month[7] = "July"; $month[8] = "August"; $month[9] = "September"; $month[10] = "October"; $month[11] = "November"; $month[12] = "December"; //Get correct month $m=$month[$m]; //send back the time in unix timestamp return strtotime("$m $d, $y"); } ?>

« previous php.notes (#134806) next »