PHP convert date from european to US format (dd/mm/yyyy => yyyy-mm-dd)
It is the right way to do the job, but surfing on the web I found an alternative way that helps me when I have to prepare a field to store into a MySql database.
$var = '20/04/2012';
echo implode("-", array_reverse(explode("/", $var)));
The code is simple and self-explanatory, anyway it explodes the source string in substrings containing dd mm and yy then reverses the order of the elements of the array and, last, rebuilds the string using the minus sign as separator.
You can find the source of this tip at this link