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
PHP & MySQL time zone
Moderator: General Moderators
-
WebbieDave
- Forum Contributor
- Posts: 213
- Joined: Sun Jul 15, 2007 7:07 am
Re: PHP & MySQL time zone
The strtotime and date functions plus a little arithmetic is all you need.
- Kieran Huggins
- DevNet Master
- Posts: 3635
- Joined: Wed Dec 06, 2006 4:14 pm
- Location: Toronto, Canada
- Contact:
Re: PHP & MySQL time zone
you can set the MySQL server timezone:
http://dev.mysql.com/doc/refman/5.0/en/ ... pport.html
http://dev.mysql.com/doc/refman/5.0/en/ ... pport.html
- RobertGonzalez
- Site Administrator
- Posts: 14293
- Joined: Tue Sep 09, 2003 6:04 pm
- Location: Fremont, CA, USA
Re: PHP & MySQL time zone
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.
And no one here is ever going to just give you code. Code it yourself and ask for help when you run into snags.
-
nadinchathura
- Forum Newbie
- Posts: 2
- Joined: Thu Jun 12, 2008 10:28 pm
Re: PHP & MySQL time zone
thanks guys...
thank you so much
Re: PHP & MySQL time zone
Check out date_default_timezone_set for on the fly timezone setting - http://www.php.net/date_default_timezone_set