RE: [PHP] Help..Date Format

From: Date: Thu, 17 May 2001 23:56:43 +0000
Subject: RE: [PHP] Help..Date Format
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-53352@lists.php.net to get a copy of this message
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 dread@texas.net -- 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.

« previous php.general (#53352) next »