Almost any date to Mysql date

Submitted by:Jhon Brain

Date added:22 July, 2014

Category:MySQL

Handy helper function which parses about any date and returns the same date in MySQL date/time format.

Tags: helper function , mysql date

Code Snippet:

FUNCTION date_to_mysql($date) {
//IF $date IS NOT NUMERIC, assume it's in textual format
if (!is_numeric($date)) {
$date=strtotime($date);
}
return date('Y-m-d H:i:s',$date);
}
 
 

Comments