DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

Snippets has posted 5883 posts at DZone. View Full User Profile

PHP Function For Converting UK Dd/mm/yyyy Format Into Yyyy-mm-dd Format For Inserting Into Mysql

02.18.2010
| 9133 views |
  • submit to reddit
        // description of your code here
Convert Mysql Date
I am Using the following function to convert mysql date format into my req.

function uk_date_to_mysql_date($date){
$date_year=substr($date,6,4);
$date_month=substr($date,3,2);
$date_day=substr($date,0,2);
$date=date("Y-m-d", mktime(0,0,0,$date_month,$date_day,$date_year));
return $date; 
} 

echo uk_date_to_mysql_date($row['date']); //// $row['date'] is in the form :yyyy-mm-dd.