470,573 Members | 1,692 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,573 developers. It's quick & easy.

Formatting a Date Stamp on Echo

RT
How would I format a timestamp which is used to show when a quote was
created in a record set.

This is the echo -
<?php echo($row_rsquote['created']); ?>

I tried doing this -
<?php echo date('D, m/d/Y',$row_rsquote['created']); ?>

but all I get is Monday, 01/18/2038.

Can anyone tell me how I can echo the value in the correct date format ?

Thanks

Jul 17 '05 #1
2 4386
RT wrote:
[Please don't send MIME encoded messages. Thank you]
How would I format a timestamp which is used to show when a quote was
created in a record set.

This is the echo -
<?php echo($row_rsquote['created']); ?>

I tried doing this -
<?php echo date('D, m/d/Y',$row_rsquote['created']); ?>

but all I get is Monday, 01/18/2038.

Can anyone tell me how I can echo the value in the correct date format ?


A TIMESTAMP returns from MySQL as, eg, "20040512171115".
You cannot apply that to the PHP date() function (or you can, but the
results are not what you expect :) ).
I'd return a UNIX_TIMESTAMP from the database instead:

select fld1, fld2, UNIX_TIMESTAMP(created) as created, fld4
from table
...
which returns something that PHP interprets correctly, sparing you the
trouble to convert the timestamp in PHP.

--
USENET would be a better place if everybody read: : mail address :
http://www.catb.org/~esr/faqs/smart-questions.html : is valid for :
http://www.netmeister.org/news/learn2quote2.html : "text/plain" :
http://www.expita.com/nomime.html : to 10K bytes :
Jul 17 '05 #2
In article <BC*********************@comcast.net>, RT wrote:
I tried doing this -
<?php echo date('D, m/d/Y',$row_rsquote['created']); ?>

but all I get is Monday, 01/18/2038.


You could also leave the formatting to mysql.
Lookup the DATE_FORMAT function in the mysql manual for more info...
--
http://home.mysth.be/~timvw
Jul 17 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by Dan Weeb | last post: by
4 posts views Thread by RT | last post: by
7 posts views Thread by lkrubner | last post: by
7 posts views Thread by Don | last post: by
3 posts views Thread by Des | last post: by
5 posts views Thread by Des | last post: by
5 posts views Thread by printdude1968 | last post: by
Tormod
9 posts views Thread by Tormod | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.