hi,
$date = "January 8 2007 11:23 pm";
and have to store it on db in datetime column as yyyy-mm-dd HH:ii:ss.
Is there any function that will "translate" $date in format I need to
store it in DB?

Right now I was thinking to do like this:

$date_new = explode(' ', $date);
switch($date_new[0])
{
  case 'January':
  $month = '01';
  break;

  case 'February':
  $month = '02';
  break;

  // etc.
}

$date_time = explode(':', $date_new[3]);
$hours = ($date_new[4] == 'pm') ? ($date_time[0] + 12) : $date_time[0] ;
$time_new = $hours.':'.$date_time[1].':00';

$date_final = $date_new[2].'-'.$month.'-'.$date_time[1].' '.$time_now;

Is there better solution than this above?

Thanks.

-afan

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to