Log in

View Full Version : Gmt time



lord22
08-07-2008, 09:54 PM
Hi

I'm trying to create a simple guest book, which should also write the date&time of the post, in the following way: 04/08/08 13:50.

In a regular PHP code I'm using GMT in order to see the right date&time, but here I don't really know what's the best way to store this kind of data in my database, and then print it, in this structure: 04/08/08 13:50.

thetestingsite
08-07-2008, 09:58 PM
I would recommend using a UNIX timestamp. Then use the date (http://php.net/date) function to format it the way you want.

Hope this helps.

motormichael12
08-08-2008, 02:49 AM
I am using what testing said, I save everything as the unix timestamp using time()

Then when you want to display, use date( format [, timestamp ] )

In all the examples I see, the timestamp is set using mktime, but I went and did my own testing and it can jsut be a unix timestamp.

lord22
08-08-2008, 10:06 AM
Thank you, I'll check this out!

Nightfire
08-09-2008, 04:24 AM
Or convert it in the sql query, by using date_format() (http://dev.mysql.com/doc/refman/5.0/en/date-and-time-functions.html#function_date-format)