[PHP] Help..Date Format

2001-05-17 Thread Jack Sasportas

OK I have asked the question before and not really gotten the answer, so
I will re-word what I am trying to do.
First I figured out that part of my problem may be how I am storing the
date into mysql from php.
Currently we are using the now() function to store the date in one field
and the time in another.  I know understand what is physically being
stored in the db.

I am trying to retreive the date value from the mysql db, and display it
on the screen in a standard format like 05/08/01.
What I get right now is 2001-05-09.
Also the time comes out like so: 227:08:22

I have tried this:
$t_data_array[1]=date(m/d/y,mysql_result($db_result,$db_record,'date'));

and the result is: 12/31/69 formatted nicely but that date is 5/9/2001
not 1969.

I have tried several suggestions and other things, but I am not being
successful.


Here is what I am trying to do:
I would like the result of the date to be formatted as 05/01/01
and the time as 18:51

Please give me some very specific instructions, this is a silly thing to
be stuck on...

   $t_data_array[1]=mysql_result($db_result,$db_record,'date');
   $t_data_array[2]=mysql_result($db_result,$db_record,'time');

THANKS !
___
Jack Sasportas
Innovative Internet Solutions
Phone 305.665.2500
Fax 305.665.2551
www.innovativeinternet.com
www.web56.net



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




RE: [PHP] Help..Date Format

2001-05-17 Thread Don Read


On 17-May-01 Jack Sasportas wrote:
 OK I have asked the question before and not really gotten the answer, so
 I will re-word what I am trying to do.
 First I figured out that part of my problem may be how I am storing the
 date into mysql from php.
 Currently we are using the now() function to store the date in one field
 and the time in another.  I know understand what is physically being
 stored in the db.
 
 I am trying to retreive the date value from the mysql db, and display it
 on the screen in a standard format like 05/08/01.
 What I get right now is 2001-05-09.
 Also the time comes out like so: 227:08:22
 
 I have tried this:
 $t_data_array[1]=date(m/d/y,mysql_result($db_result,$db_record,'date'));
 
 and the result is: 12/31/69 formatted nicely but that date is 5/9/2001
 not 1969.
 
 I have tried several suggestions and other things, but I am not being
 successful.
 
 
 Here is what I am trying to do:
 I would like the result of the date to be formatted as 05/01/01
 and the time as 18:51
 
 Please give me some very specific instructions, this is a silly thing to
 be stuck on...
 
$t_data_array[1]=mysql_result($db_result,$db_record,'date');
$t_data_array[2]=mysql_result($db_result,$db_record,'time');
 

A. Have MySQL do the formatting:
  select DATE_FORMAT('%m/%d/%y %r', mydate) as da_date from ...

B. parse it and let PHP do the heavy lifting:
list ($y, $m, $d, $h, $i, $s)=explode('- :', $row-mydate);
$da_date=strftime('%D %r', mktime($h, $i, $s, $m, $d, $y);

Regards,
-- 
Don Read   [EMAIL PROTECTED]
-- It's always darkest before the dawn. So if you are going to 
   steal the neighbor's newspaper, that's the time to do it.

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]