When I run a simple php file called test.php (placed in the root of the wp installation) that contains something like that:
<?php echo date('H:i:s'); ?>
The result is right: 15:30:00
and the timezone is set also correctly to Europe/Prague which is UTC+2 time
However, if I place the same line within my e.g. footer or sidebar or even index file of my template than the result is 13:30:00
which is UTC time.
The same in my custom plugin in WP admin. the time is 2 hours late.
The time in admin options is set correctly to UTC+2.
What is funny that if I create a new post or page the time is correct 15:30:00. I don't get it.
Any idea why this happens?
I have the latest fresh WP installation. 3.5.1 CZ version without any installed plugins.
UPDATE:
I have tried using WP function date_i18n() like:
<?php echo date_i18n('H:i:s'); ?>
and it's working as expected.
However:
<?php echo date('H:i:s'); ?>
and it's still not working right. But outside wordpress date()
is working correctly.
Why is that? Why is wordpress screwing up date()
function ?