![]() |
|
|
|||||||
| Register | Forum FAQ | Search | Today's Posts | Mark Forums Read |
|
|
LinkBack | Thread Tools | Display Modes |
|
||||
|
what is the best way to set the default timezone for php scripts?
I have attempted: PHP Code:
Any suggestions would be greatly appreciated.
__________________
Milwaukee Website Design Company |
|
||||
|
Hey, Scott
What PHP version we're talking about? I presume PHP5... You can try also using bool date_default_timezone_set ( string $timezone_identifier ) Timezones list: PHP: List of timezones in the group America - Manual Documentation on your issue: PHP: date_default_timezone_set - Manual However, I'd suggest saving all date\time value in UTC & than add timezone offset before the output. This is better than to write to users from Japan that all times are UTC -6 or something like that. Let me know how it goes |
|
||||
|
Alright, I got the php part to work but I am now having trouble with MySQL now().
Here is the code that I have so far: PHP Code:
PHP Code:
PHP Code:
PHP Code:
Per MySQL doc: Named time zones can be used only if the time zone information tables in the mysql database have been created and populated. Can we get these tables loaded or is there another solution to get now() to work as expected?
__________________
Milwaukee Website Design Company |
|
||||
|
No takers?
Am I the only one with this issue? What are others doing to work around this?
__________________
Milwaukee Website Design Company |
|
||||
|
I just use #'s. I only have to report one or two timezones, so I have no need for this sort of complication, so Im not a taker, sorry.
Here are the tables. MySQL :: Time zone description tables You can open a supprt ticket and give that link then make a request to have it installed in the mysql DB. |
|
||||
|
So you do this ...
"set time_zone = '-5:00'" How do you handle daylight savings time?
__________________
Milwaukee Website Design Company |
|
||||
|
We are in the same boat.
I was also looking for a way to set a domains timezone through CPanel because server logs are also annoying with the timestamps written to system time. Or possiblely through some Apache directive that could be added to htaccess file. I am going to check further on the Apache thing and post back results.
__________________
Milwaukee Website Design Company |
|
||||
|
Well you can set your env variable using an Apache directive. Place this line in your .htaccess file in your document root directory:
SetEnv TZ America/Chicago After placing this in my .htaccess file, PHP works like a champ and you no longer have to make the adjustment in your PHP code. However, MySQL still requires the per connection manipulation.
__________________
Milwaukee Website Design Company |
|
||||
|
The scripts I have seen, have a checkbox which adjusts the script settings/clock by one hour when it is checked, or not checked respectively. But really, if PHP is using the server time then the time should always be right since that clock is updated by rdate.
As for MySQL, I have no idea, if anyone finds it, I'd be interested in it for a script I am working on as well.
__________________
::::: 01001100 00110011 00110011 00110111 Last edited by Matt; 03-13-2008 at 09:05 PM. |