There is a difference between MySQL's timestamp, and a UNIX timestamp.
strtotime(); is a really valuable tool -- converting almost any English date
description -- check out the manual for more info.
Anyway, in this case, it is able to convert your MySQL date of 20020409 into
a unix timestamp, which is the required format for date() formatting.
In clear code:
<?
$date = "20020409";
$date_unix = strtotime($date);
$date_f = date('jS M Y',$date_unix);
echo $date_f."<BR>";
?>
Although this can be condensed to:
<?
$date = "20020409";
$date_f = date('jS M Y',strtotime($date));
echo $date_f."<BR>";
?>
or even just
<?
$date = "19770417";
echo date('jS M Y',strtotime($date));
?>
Check out:
http://www.php.net/manual/en/function.date.php
http://www.php.net/manual/en/function.strtotime.php
for more info and date() formats.
Note: I haven't done a heap of testing with strtodate() to ensure it's going
to return what you expect, but I randomly tested 10 dates in your format
between 1977 and 2002 without any problems.
Justin French
--------------------
Creative Director
http://Indent.com.au
--------------------
on 09/04/02 9:53 PM, nyon ([EMAIL PROTECTED]) wrote:
> Hi,
>
> I need to recall a date data in a MySQL database.
> The column is set as "date timestamp(8)".
> A sample of date is "20020409"
>
> I use the PHP Date function to format it back to say "9th April 2002".
> $date_formated = date($date, 'S M Y' );
> However, it's still doesn't appear as formatted.
>
> Anyone mind sharing their code to do this?
>
> Nyon
>
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php