note 80203 added to function.strtotime

From: Date: Fri, 04 Jan 2008 04:46:34 +0000
Subject: note 80203 added to function.strtotime
Groups: php.notes 
Request: Send a blank email to php-notes+get-134754@lists.php.net to get a copy of this message
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"); } ?> ---- Server IP: 69.147.83.197 Probable Submitter: 75.57.181.197 ---- Manual Page -- http://www.php.net/manual/en/function.strtotime.php Edit -- https://master.php.net/note/edit/80203 Del: integrated -- https://master.php.net/note/delete/80203/integrated Del: useless -- https://master.php.net/note/delete/80203/useless Del: bad code -- https://master.php.net/note/delete/80203/bad+code Del: spam -- https://master.php.net/note/delete/80203/spam Del: non-english -- https://master.php.net/note/delete/80203/non-english Del: in docs -- https://master.php.net/note/delete/80203/in+docs Del: other reasons-- https://master.php.net/note/delete/80203 Reject -- https://master.php.net/note/reject/80203 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#134754) next »