Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Live API: lastMinutes is modified by timezone #3925

Closed
LeCoyote opened this issue May 6, 2013 · 2 comments
Closed

Live API: lastMinutes is modified by timezone #3925

LeCoyote opened this issue May 6, 2013 · 2 comments
Labels
Bug For errors / faults / flaws / inconsistencies etc. worksforme The issue cannot be reproduced and things work as intended.

Comments

@LeCoyote
Copy link

LeCoyote commented May 6, 2013

When calling the API in PHP, the value of the lastMinutes parameter is affected by the timezone of the calling code.

In this one instance where the site is running in the Europe/Paris timezone, if lastMinutes < 120, the API will always return 0 visits. This is obviously because the visits are stored in UTC and the calling code is 2 hours ahead of UTC (CEST). By requesting lastMinutes = N + 120, I get the corresponding visits for the last N minutes.

This bug/feature is undocumented and should definitely be handled by the API.

This happens regardless of whether the API is called by including Piwik's index.php or not (ie. including Loader.php + using more define()s etc.)
Keywords: API Live

@mattab
Copy link
Member

mattab commented May 7, 2013

Maybe the problem is that you use a non UTC server, but Piwik is designed to be running in UTC (PHP timezone). Reopen if I'm wrong, but we won't fix it if you do not use:

@date_default_timezone_set('UTC');

@LeCoyote
Copy link
Author

LeCoyote commented May 7, 2013

I won't reopen, but this means that you are forcing every website that wishes to use a UTC timezone and not event documenting it? I mean, it is one thing to say that Piwik runs in UTC internally, but there is never a reference to the fact that lastMinutes is influenced by timezone, or that calling the API in PHP must be done in UTC.

Just FYI, simply offseting the lastMinutes parameter by a simple date('Z')/60 is enough to fix this behaviour and therefore refraing from enforcing any timezone constraint to the outside code.

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug For errors / faults / flaws / inconsistencies etc. worksforme The issue cannot be reproduced and things work as intended.
Projects
None yet
Development

No branches or pull requests

2 participants