CoderZone.org

Category: >> mySQL >> Almost any date to Mysql date Bookmark and Share

<< lastnext >>

Snippet Name: Almost any date to Mysql date

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

Comment: (none)

Author: CoderZone
Language: MYSQL
Highlight Mode: MYSQL
Last Modified: March 01st, 2009

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);         
}
 
There haven't been any comments added for this snippet yet. You may add one if you like.  Add a comment 
© coderzone.org | users online: 7