Home >> Snippet List >> Snippet

Name
Convert UK Dates To mySQL Format Dates
Description
Handy function that will convert a UK date style (dd/mm/yyyy) into a into a mySQL format (yyyy-mm-dd)
PHP Snippet
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; 
 
} 
 
// $row['date'] is in the form: yyyy-mm-dd.
ECHO uk_date_to_mysql_date($row['date']);