Imaginx
asked on
converting date formats
need a function to convert m-d-Y or Y-m-d
i want to run the function anytime a date variable is used & only modify the variable data IF it fits the format to be modified.
in layman's terms:
if( *date* == format m-d-Y){ convert to Y-m-d )
i want to run the function anytime a date variable is used & only modify the variable data IF it fits the format to be modified.
in layman's terms:
if( *date* == format m-d-Y){ convert to Y-m-d )
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
$s = '03-05-2011';
$t = strtotime($s);
if (!$t) die("$s is a bogus date string");
$d = date('Y-m-d', $t);
echo $d;