Re: Re: strtotime problem

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 8 Oct 2008, at 12:42, Nathan Rixham wrote:
Thodoris wrote:
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) ));
}

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)
{
    list($day, $month, $year) = explode('/', $webdate);
    return $year.'-'.$month.'-'.$day;
}

-Stut

--
http://stut.net/

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux