Re: Re: strtotime problem
| From: | Stut | Date: | Wed, 08 Oct 2008 11:47:57 +0000 |
| Subject: | Re: Re: strtotime problem | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-281585@lists.php.net to get a copy of this message | ||
On 8 Oct 2008, at 12:42, Nathan Rixham wrote:
Thodoris wrote:What exactly do you expect strtotime('80023010') to return? I tend to always normalise dates to Y-m-d before pushing them into strtotime, but in your case you don't need to do that. If you *know* the date always comes in as that format you can simply do this... function dateWebToMysql($webdate) {I know that *strtotime*() only recognises the formats mm/dd/yyyy, yyyy-mm-dd and yyyymmdd ****for numeric months but I need do something like that: function dateWebToMysql($webdate){ $format = 'Y-m-d'; $timestamp = strtotime($webdate); return date($format,$timestamp); } print dateWebToMysql('01/03/2008'); Where 01/03/2008 is in dd/mm/yyyy format (not the American format). What is the best way of doing this? Any ideas?completely random and never used myself [ie just made it up] function dateWebToMysql( $webdate ){ return strtotime(strrev( str_replace('/','', $webdate) )); }
list($day, $month, $year) = explode('/', $webdate);
return $year.'-'.$month.'-'.$day;
}
-Stut
--
http://stut.net/