As the title says, can anybody explain why the code
ini_set( \'date.timezone\', \'Europe/Athens\' );
works but
date_default
You must be using an old version of PHP.
date_default_timezone_set is for PHP 5.1.2 and above.
Try php -v and check your PHP version.
You can use:
putenv("TZ=Europe/Berlin"); // PHP 4
localhost
server
It's quite late, I got the same issue and I see there is the difference, I post the screenshot from my localhost and my personal server phpinfo for the timezone.
On my localhost, date_default_timezone_set('[timezone]') works correctly, however, on the server, it always return the UTC. Based on the php doc, it looks like the timezone is not set in the php ini of my server, so i likely ignored the the timezone set since no value is defined previously.
Using the init_set, it makes the timezone to be available. I think the timezone is not predefined on the php ini is the cause.