Why does PHP consider the system's timezone unreliable, and is date_default_timezone_set() required?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is probably a familiar error for anyone using PHP:

> Message: date() [function.date]: It is not safe to rely on the system's timezone
> settings. You are required to use the date.timezone setting or the
> date_default_timezone_set() function.

I know *what* this error means, I don't quite understand why PHP considers the
system's timezone unreliable?
All other programming languages I've used just use the systems timezone without
problems, and most applications (servers applications, desktop apps) just use
the system setting.

For example, in C:

#include <time.h>
#include <stdio.h>

int main() { 
    char out[255];
    time_t now = time(0);
    struct tm *ltime = localtime(&now);

    tzset();
    strftime(out, sizeof(out), "%z, %Z", ltime);
    printf("%s\n", out);
}

Gives me: +0100, CET, which is the expected output.

Is this somehow unreliable? This is all POSIX stuff, so I would expect it to
work well on at least all POSIX sysyems, or am I missing something?


PS. Please CC me, as I am not subscribed to this list!

Thanks,
Martin

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php





[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux