Page 1 of 1

PHP & MySQL time zone

Posted: Thu Jun 12, 2008 10:35 pm
by nadinchathura
Hey guys,

My servers are allocated in USA. Normally when i save time using MySQL NOW() function, time saved on DB in USA time. At the time of retrieving time from PHP i get USA time. how can i change it to Sri Lankan time zone which is equals to Sri Lanka current time?

Please give me some code to do this.

Thak guys

Chathu

Re: PHP & MySQL time zone

Posted: Fri Jun 13, 2008 11:47 am
by WebbieDave
The strtotime and date functions plus a little arithmetic is all you need.

Re: PHP & MySQL time zone

Posted: Fri Jun 13, 2008 12:16 pm
by Kieran Huggins
you can set the MySQL server timezone:
http://dev.mysql.com/doc/refman/5.0/en/ ... pport.html

Re: PHP & MySQL time zone

Posted: Fri Jun 13, 2008 1:15 pm
by RobertGonzalez
And you can set the PHP timezone in php.ini

And no one here is ever going to just give you code. Code it yourself and ask for help when you run into snags.

Re: PHP & MySQL time zone

Posted: Fri Jun 13, 2008 8:50 pm
by nadinchathura
thanks guys... :D thank you so much

Re: PHP & MySQL time zone

Posted: Fri Jun 13, 2008 9:01 pm
by Eran
Check out date_default_timezone_set for on the fly timezone setting - http://www.php.net/date_default_timezone_set