[nycphp-talk] Help converting MySQL datetime to month
Randal Rust
randalrust at gmail.com
Thu Oct 19 21:28:36 EDT 2006
I have a function that does what I want, I just find it hard to
believe that there isn't something better. So any pointers would be
greatly appreciated.
function convertDatetime($value){
$value=explode(" ", $value);
$value=explode("-", $value[0]);
$y=$value[0];
$m=$value[1];
$d=$value[2];
switch($m){
case '01':
$m='January';
break;
case '02':
$m='February';
break;
case '03':
$m='March';
break;
case '04':
$m='April';
break;
case '05':
$m='May';
break;
case '06':
$m='June';
break;
case '07':
$m='July';
break;
case '08':
$m='August';
break;
case '09':
$m='September';
break;
case '10':
$m='October';
break;
case '11':
$m='November';
break;
case '12':
$m='December';
break;
}
$dt=$m.' '.$d.', '.$y;
$value=$dt;
return $value;
}
--
Randal Rust
R.Squared Communications
www.r2communications.com
More information about the talk
mailing list