RE: [PHP-DB] date format display

2002-06-10 Thread Gary Pullis

This is how I'd do it:
$strtime = "20020531"; // Example date string

// STEP 1: Turn the MMDD 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




Re: [PHP-DB] date format display

2002-06-10 Thread Paul Burney

on 6/10/02 9:00 AM, fabrizio at [EMAIL PROTECTED] appended the following bits
to my mbox:

> 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 ?

In your query, you can use the MySQL date_format function.  See the
documentation here:



Example:

SELECT movie_title, DATE_FORMAT(movie_start_date, '%m/%d/%Y') AS
start_date_formatted FROM movies_table WHERE movie_id="3";

Hope that helps.

Sincerely,

Paul Burney






-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP-DB] date format display

2002-06-10 Thread Manuel


 This function will fix your date display. 
$sqldate="20020531";
$sqldate= fixdate($sqldate); 

function fixdate($data){
 $aux="";
 $z=0;
 for($i=0; $i wrote: 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





~ Manuel Ochoa ~
Seven days is too long to wait for a gun!



-
Do You Yahoo!?
Sign-up for Video Highlights of 2002 FIFA World Cup


Re: [PHP-DB] date format display

2002-06-10 Thread Stuart Dallas

Monday, June 10, 2002, 2:00:59 PM, you wrote:
> 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 ?

Look at date and strtotime...

http://www.php.net/date
http://www.php.net/strtotime

Also take a look at DATE_FORMAT in the MySQL manual...

http://www.mysql.com/doc/D/a/Date_and_time_functions.html

-- 
Stuart


-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php