View Full Version : Converting to Date

08-12-2007, 10:11 PM
Hey guys,

I collect some data from a user registration form in the format:

Day: 1-31 Month: 1-12 Year- 1990-2007

I was wondering, how i can convert this into proper date format so i can store it in my database :P?

08-12-2007, 10:23 PM
I'm assuming you meant that hyphen to be a colon after year:

$string = 'Day: 12 Month: 8 Year: 2007';
$array = array_filter(explode(' ', $string));
$date = implode('-', array($array[5], $array[3], $array[1]));
// $date = '2007-8-12';