Forum Moderators: coopster

Message Too Old, No Replies

Problem with Date and Time Variable with Database

         

naitsirhc26

4:00 pm on Aug 31, 2007 (gmt 0)

10+ Year Member



Hello,

Here is my code:
<?php echo time( $details[ 'last_updated' ], 'g:i a');?>

Since I am still learning PHP, I think I screwed my code up.

Basically, I am trying to display the time that a blog was last updated, from a table in a database. last_updated being the table details. And I want to display the time information with the structure of g:i a.

Do you see where I went wrong?

Thanks,

Christian

dreamcatcher

5:08 pm on Aug 31, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



You can let the database do the work.

SELECT *,DATE_FORMAT [dev.mysql.com](last_updated,'%H:%i %s') AS new_date FROM table...

echo $details['new_date'];

dc

naitsirhc26

5:14 pm on Aug 31, 2007 (gmt 0)

10+ Year Member



Would there be a way I could do this without touching my database? (I don't know if I would feel comfortable adding a new table to my database. There is a lot of valuable info on there)

coopster

8:33 pm on Sep 3, 2007 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



The solution offered was not one to update the database, Christian, but to show you how you might format the date you are retrieving from the database using a date function.