Click to See Complete Forum and Search --> : date conversion


mahfooz
10-28-2006, 05:46 AM
how to convert date from 2006-11-28 to 2006-nov-28 while first date comes from database

pcthug
10-28-2006, 06:23 AM
$old_date = '2006-11-28';

$d = explode('-', $old_date);
$new_date = "{$d[0]}-" . strtolower(date('M', mktime(0, 0, 0, $d[1], 1, 0))) . "-{$d[2]}";

NogDog
10-28-2006, 10:50 AM
You may want to do the conversion as part of your DB query. For instance, if using MySQL, you can use its DATE_FORMAT() function to return the date in the desired format. (See the date and time functions (http://dev.mysql.com/doc/refman/4.1/en/date-and-time-functions.html) page.)