@davidn at datalinktech dot com dot au
set_default_timezone() has no effect at all on how apache logs are timestamped (at least for me)
[red. that's untrue if you set the TZ env var... that will affect Apache as well - Derick]
It is however true, that all dates and times that php formats that are _not_ timestamps will be in that timezone.
Timestamps are always GMT
date_default_timezone_set
(PHP 5 >= 5.1.0)
date_default_timezone_set — スクリプト中の日付/時刻関数で使用されるデフォルトタイムゾーンを設定する
説明
bool date_default_timezone_set
( string $timezone_identifier
)
date_default_timezone_set() は、日付/時刻関数で 使用されるデフォルトタイムゾーンを設定します。
注意: PHP 5.1.0 以降(日付/時刻 関数が書き直されてから)、タイムゾーンを 正しく設定せずに日付/時刻関数をコールすると E_NOTICE が発生し、またシステムの設定や TZ 環境変数を 使用すると E_STRICT が発生するようになりました。
スクリプト内でこの関数を使用してデフォルトタイムゾーンを設定するかわりに、 INI 設定 date.timezone でデフォルトタイムゾーンを設定することもできます。
パラメータ
- timezone_identifier
-
タイムゾーン ID 。例えば UTC や Europe/Lisbon など。有効な ID の一覧は サポートされるタイムゾーンのリスト にあります。
返り値
この関数は、timezone_identifier が 無効なものである場合に FALSE、それ以外の場合に TRUE を返します。
変更履歴
| バージョン | 説明 |
|---|---|
| 5.1.2 | timezone_identifier パラメータの内容を 検証するようになりました。 |
date_default_timezone_set
php_manual at lk2 dot de
12-Aug-2007 01:37
12-Aug-2007 01:37
PeerGoal.com
12-Feb-2007 04:21
12-Feb-2007 04:21
The problem:
date() [function.date]: It is not safe to rely on the system's timezone settings. Please use the date.timezone setting, the TZ environment variable or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'America/Los_Angeles' for 'PST/-8.0/no DST' instead
Of course this is a problem that recently surfaced since PHP5. Quick fix is to set your time zone, add this line to your php code:
date_default_timezone_set("America/Los_Angeles");
davidn at datalinktech dot com dot au
21-Dec-2006 05:27
21-Dec-2006 05:27
Note that there may be some unexpected side-effects that result from using either set_default_timezone() or the putenv("TZ=...") workalike for earlier PHP versions. ANY date formatted and output either by PHP or its apache host process will be unconditionally expressed in that timezone.
[red. That is only true for the putenv() hack - Derick]
This does indeed include the web server's logs and other output files and reports which by default usually do not include any indication of timezone. This has a further side-effect on log processing and analysis, obviously.
