Uk timestamp required: mysql

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
User avatar
raghavan20
DevNet Resident
Posts: 1451
Joined: Sat Jun 11, 2005 6:57 am
Location: London, UK
Contact:

Uk timestamp required: mysql

Post by raghavan20 »

I have got a table where I want to store the timestamp created by mysql not php. The time stamp it gives is not UK time, is it possible to get UK time?
User avatar
Burrito
Spockulator
Posts: 4715
Joined: Wed Feb 04, 2004 8:15 pm
Location: Eden, Utah

Post by Burrito »

create a date, time or datetime field on the database you must. Store the value in its native format it will. Using the php date() function or the mysql date_format function, format the date/time how you want you can.
User avatar
raghavan20
DevNet Resident
Posts: 1451
Joined: Sat Jun 11, 2005 6:57 am
Location: London, UK
Contact:

Post by raghavan20 »

I have seen this date_format() which is used in 'select' statement to format the date received from the db.

But I want to the db to store UK timings instead of US timings because my host is in US. Is it possible to store UK timings in the db using any default value in the timestamp field? If not possible to set in mysql, tell me a function by which I can get GMT timing.
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post by Chris Corbyn »

If you know the GMT offset then

Code: Select all

INSERT INTO `table` (`time_stamp`) VALUES (NOW()+(60*60*X))
Where X is the GMT offset in hours (negative or positive).
Post Reply