[RESOLVED] Mysql Timestamp and PHP - Best way to display time
I have searched the Net and come up empty-handed; I wonder if anyone here could assist me in resolving this issue.
I would like the data stored in a MySQL TIMESTAMP field to be called and displayed using PHP. I have already created the necessary MySQL columns in a table to record the date of creation and the date of modifiction, and a script to insert them into the table:
$query = "INSERT INTO articles VALUES
(See attached graphic for a screenshot of the corresponding table.)
This process works great; however, my problem arises when I retrieve the data from the database. The date is stored in this format:
2010-12-24 06:51:26, and when I pull the date into the webpage by merely assigning the data in that field a variable and calling the variable, it is displayed on the webpage exactly as it is stored in the database.
1) know how to change the timezone and / or format the date to a more user friendly format - between the time the date leaves the database and the time that it is printed on the page?
2) have a better way of storing dates than the MySQL method that I am using?
All help will be greatly appreciated.
Last edited by Mr. Baggins; 12-24-2010 at 10:17 AM.
Reason: forgot to attach graphic
I don't know half of you half as well as I should like; and I like less than half of you half as well as you deserve.
- Bilbo Baggins in The Fellowship of the Ring
That's the best way but I find myself using PHP to grab data using lots of slightly different versions of SQL. I can never remember which method of formatting the date goes with which version of SQL so I post process with SQL.
echo date ('j M Y', strtotime ($a_row['publishDate']));
“The power of the Web is in its universality. Access by everyone regardless of disability is an essential aspect.”
—Tim Berners-Lee, W3C Director and inventor of the World Wide Web