This is how I'd do it:
$strtime = "20020531"; // Example date string
// STEP 1: Turn the YYYYMMDD string into a UNIX date
$unixtime = mktime(substr($strtime, 8, 2),substr($strtime, 10,
2),0,substr($strtime, 4, 2),substr($strtime, 6, 2),substr($strtime, 0, 4));
// STEP 2: Use the date() function to format the date however you'd like
echo date("m-d-Y", $unixtime); // Outputs 05-31-2002 echo date("d/m/Y",
$unixtime); // Outputs 31/05/2002
Things I highly recommend reading:
http://www.php.net/manual/en/function.substr.php
http://www.php.net/manual/en/function.mktime.php
http://www.php.net/manual/en/function.date.php
You'll really want to read the page about the date function. The options for
formatting your date output are just about limitless.
Gary Pullis
Office Management Technologies
http://www.omt.cc
> -----Original Message-----
> From: fabrizio [mailto:[EMAIL PROTECTED]]
> Sent: Monday, June 10, 2002 9:01 AM
> To: [EMAIL PROTECTED]
> Subject: [PHP-DB] date format display
>
>
> Hello dear all,
>
> in my mysql-db I have a date_tbl with this format: (20020531).
> how is possible in PHP do display date_tbl's values in a more
> human-readable
> format like 05-31-2002 or 31/05/2002 ?
>
> thaks in advance,
> regards
>
> fabrizio
>
>
>
>
> --
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php