It seems piwik is resetting the default timezone in php with every call to the API.
In my code, after these 2 lines:
require_once PIWIK_INCLUDE_PATH . “/index.php”;
require_once PIWIK_INCLUDE_PATH . “/core/API/Request.php”;
My timezone stuff goes wrong. Whats worse is that it is corrupting phps date() function.
If I use date(‘I’) before those lines, it’s fine. I get a 1 (DST is being used). If I use it after I get 0. If I then use:
and then call date(‘I’) again it’s fine… until I call the API somewhere in the code.
Looking at the timestamps from time() they’re all correct BUT the times are being formed 1 hour behind London time (GMT +1 currently).
For example: it’s 17:49 now. If I get date(‘H:i:s’) before any piwik code it will give me the correct time. After those two require lines of code it will show 16:49 instead. The same applies all throughout the code.
I have checked my piwik settings, they are set to London in the root settings. The default timezone for new websites is London… yet the little i box shows UTC is an hour behind. It seems that piwik is sticking to UTC for everything.
So, to recap:
- date() doesn’t work correctly
- times are returned one hour behind.