#native_company# #native_desc#

Date conversion

By Jeff
on June 15, 2005

For the most part anything I code I need to convert between mysql date style, U.S. date style, and unix timestamp. There are a lot of date conversion functions out there but anything I usually do up and beyond this simple conversion function is pretty specific to the application.
I always validate my dates before I submit for conversion.

In any case, I thought I would share this with you all.

if ($converted_date=date_conversion($date)){
     print $converted_date->unix_timestamp;
     print "Date format is not recognized";

function date_conversion($date){
     if(eregi("([0-9]{4})-([0-9]{1,2})-([0-9]{1,2})",$date) ||
     }elseif(is_int($date) && $date>0){//is a probably a unix date
         return false;//date format not recognized
     return $return_date;