On 26 Apr 2007 in macromedia.dreamweaver.appdev, Buzby wrote:
> Joe Makowiec wrote:
>
>> On 26 Apr 2007 in macromedia.dreamweaver.appdev,
Buzby wrote:
>>
>> > How do you format a date variable?
>> >
>> > I've a variable call $DisplayDate which is
pulled from the DB in
>> > a loop and is showing 2007-04-26 - I want to
get it to display
>> > Thu 26 April 2007.
>>
>> My personal preference is to do it on the MySQL
side:
>>
>> SELECT DATE_FORMAT(myDatefield, '%a %e %M %Y) AS
myFormattedDate,
>> myOtherField FROM myDatabase ...
>>
>>
http://dev.mysql.com/doc/refman/5.0/en/date-and-time-functions.html
>
> <fx: sound of small denomination coin hitting the
floor>
>
> Thanks - that never occured to me!
It probably matters little whether you do it in MySQL or PHP.
And PHP
is good about converting MySQL dates (YYYYMMDD) into Unix
timestamps.
I just have this thing about screwing around with Unix
timestamps
unless I need to do date arithmetic. Just For The Record:
<?php
$format = 'D j F Y';
$formattedDate = date($format, strtotime($mysqlDate));
?>
http://www.php.net/manual/en/function.strtotime.php
--
Joe Makowiec
http://makowiec.net/
Email:
http://makowiec.net/contact.php