@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 — Sets the default timezone used by all date/time functions in a script
Description
date_default_timezone_set() sets the default timezone used by all date/time functions.
Note: Since PHP 5.1.0 (when the date/time functions were rewritten), every call to a date/time function will generate a E_NOTICE if the timezone isn't valid, and/or a E_STRICT message if using the system settings or the TZ environment variable.
Instead of using this function to set the default timezone in your script, you can also use the INI setting date.timezone to set the default timezone.
Parameters
- timezone_identifier
-
The timezone identifier, like UTC or Europe/Lisbon. The list of valid identifiers is available in the List of Supported Timezones.
Return Values
This function returns FALSE if the timezone_identifier isn't valid, or TRUE otherwise.
ChangeLog
| Version | Description |
|---|---|
| 5.1.2 | The function started to validate the timezone_identifier parameter. |
date_default_timezone_set
12-Aug-2007 09:37
12-Feb-2007 12: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");
22-Dec-2006 01: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.
