On Oct 8, 2008, at 7:08 AM, 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?
Actually strtotime accepts all kinds of things... "Last week Thursday
midnight" for example works perfectly.
You could do an explode on the field and then reorder the array anyway
that you want...
<?PHP
$date = "13/01/2008";
$datearray = explode("/", $date);
echo $datearray[1] ."/". $datearray[0] . "/" . $datearray[2];
?>
Or something like that :)
That wasn't tested but should give you an idea...
php.net/explode for more info.
This is what I was doing before (which is a bit lame) so I am looking
for a more elegant way using timestamps.
--
Thodoris
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php