473,404 Members | 2,137 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,404 software developers and data experts.

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 4524
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Dan Weeb | last post by:
Hi All, I have struggled through this far with help from many of you so thanks. I am stuck again. I am really new to this so don't be harsh :-) There are a few problems. You can run the script...
4
by: RT | last post by:
If anyone can help that would be great. Iım trying to format a timestamp from my MySQL table (sessions) Hereıs the code Iım using: <?php echo date('D,n-j-y h:i:s...
7
by: lkrubner | last post by:
This might be an idiot question, but how do you group by timestamps by date? I mean, given a large number of timestamps, spanning many months, how do grab them and say how many are from each day?...
7
by: Don | last post by:
Hi all, With regards to the following, how do I append the datetimestamp to the filenames in the form? The files are processed using the PHP script that follows below. Thanks in advance,...
3
by: Des | last post by:
I am trying to write a date and time stamp to a file Date("d-m-y") is ok but time(void) gives me 1124528448 Can I format time into a H:M:S format Desmond.
5
by: Des | last post by:
I have to do an events calender for a church. The events display will be limited to that week. If someone went in today Wed 24th I want to display 21st to 27th. I dont want any code samples, just...
7
by: Gucci | last post by:
<?php /** * check ine year is a leap year, and return the month day array * * @param int $year **the year must bigger than zero** * @return array */ function is_leap_year($year){...
5
by: printdude1968 | last post by:
Hi Everyone... I'm a newbie to this stuff so bear with me. I have a well formed xml document (I use jdom to verify) <?xml version="1.0" encoding="ISO-8859-1"?> <print-control>...
9
Tormod
by: Tormod | last post by:
I'm having problems formatting a date retrieved from mysql database. When I retrieve the date it's in the format YYYY-MM-DD. I need to split the Day, Month and Year portions of the date up so that I...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.