Page 1 of 1

MySql time problem

Posted: Thu Feb 11, 2010 2:59 am
by itsmani1
Hi,

I am using a shared hosting which has EST US time, since i am on shared hosting that's why i cannot change the server time zone but i wanted to display local Pakistan time to my users. For example a user lists an item he/she wants to see at what time item was listed and they wanted to see it in Pakistan time not EST US time.

What's the best solution to do this? Wanted to do it on database level..

Thanks
-Mannan

Re: MySql time problem

Posted: Thu Feb 11, 2010 3:02 am
by pbs
You can set time zone using date_default_timezone_set() function

Re: MySql time problem

Posted: Thu Feb 11, 2010 3:21 am
by itsmani1
date_default_timezone_set()

is a php function my time is stored in mysql sir

Re: MySql time problem

Posted: Thu Feb 11, 2010 4:51 am
by Weirdan
You can set sql session timezone on a connection:
[sql] SET session time_zone="Asia/Karachi"; [/sql]
After that all TIMESTAMP values will be auto-converted to the specified timezone upon retrieval (date and datetime values will not be affected though).