note 15819 deleted from function.mktime by jimw
| From: | jimw@php.net | Date: | Thu, 04 Oct 2001 02:35:12 +0000 |
| Subject: | note 15819 deleted from function.mktime by jimw | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-18548@lists.php.net to get a copy of this message | ||
To format a MySQL date-time variable, use the following function. Pass in the string to format the
date the same as you would with date(), only the second parameter is a MySQL formatted (i.e.
straight from the database, unchanged) date-time variable.
function date_format($format, $mysql_date_time) {
list($date, $time) = explode(" ", $mysql_date_time);
$date_part = explode("-", $date);
$time_part = explode(":", $time);
return date($format,
mktime($time_part[0], $time_part[1], $time_part[2],
$date_part[1], $date_part[2], $date_part[0]));
}
calling the function like this:
print date_format("F j, Y, g:i a", "2001-10-03 20:51:39");
...will result in...
October 3, 2001, 8:51 pm