views:

36

answers:

1

Hi,

I have date stored in my mysql table as "2010-01-01 01:01:01"

but when i query the date with date_format command like

DATE_FORMAT( date_created, '%%m-%%d-%%y (%%h:%%i %%p)' ) as cdate

I am getting a converted date basing on mysql system timezone.. i.e. few hours difference..

for that i have used query :

"SET GLOBAL time_zone = '+5:30'"
"SET SESSION time_zone = '+5:30'"

But still mysql query delivering converted date... i want to get the date exactly which is stored in that table without adding/subtracting timezone differencess.

Please help. I am really stuck.

A: 
SET SESSION time_zone = SYSTEM;

or

SET SESSION time_zone = '+0:0'; -- for UTC time if server TZ is set correctly. 
Imre L
I have run the command SELECT @@global.time_zone, @@session.time_zone; above query also returnign +0:00.. But still it is converting time to other timezone..pls help...
Satish Kalepu
then this is the time that is stored in there. Date and time columns were converted to UTC according tz that were in effect before storing it in tables. If you want same time when you stored it you need to set the same timezone when you stored it.
Imre L
Database still returning correct time . when run this query : select date_created from table .. but it is converting when i used the command:select DATE_FORMAT( date_created, '%%m-%%d-%%y (%%h:%%i %%p)' ) as cdate from table Pls helpppp
Satish Kalepu
are you sure you are setting the TZ in the same session?also i believe you need to use single %-s. Whats the output of ` Select date_created, DATE_FORMAT( date_created, '%m-%d-%y (%h:%i %p)' ) as cdate;`?
Imre L