Can be reproduced with this URL: http://demo.piwik.org/?module=API&method=Live.getLastVisitsDetails&idSite=7&period=day&date=last10&format=json&token_auth=anonymous&translateColumnNames=1
In the example there is
period=day&date=last10 and it results in an error
Error: Date format must be: YYYY-MM-DD, or 'today' or 'yesterday' or any keyword supported by the strtotime function (see http://php.net/strtotime for more information):
Even if I change the URL to date=today I get the following error: "Error: RSS feeds can be generated for one specific website &idSite=X. Please specify only one idSite or consider using &format=XML instead." Changing idSite after that doesn't seem to help.
For RSS it's normal, switch format to XML and they bug is still the same
Found another issue regarding strtotime I use it to get the data for the past 12 months.
Steps to reproduce:
To get the data for the same month last year, I use this:
To get the data for last month I use this:
To get the data for all months from last year to last month I tried to use this:
But it fails.
When I use
the data is available.
Another example is the following:
gets me the data of the previous 6 days splitted per day (excluding today)
One would think the API following call:
would return the data of the previous 6 weeks, splitted per week
would return the data of the previous 6 months, splitted by month.
However it does not.
last%20year are not supported formats. See http://developer.piwik.org/api-reference/reporting-api under
date. As magic keywords only
yesterday are supported as well as eg
There it says re
previousX returns the last X periods before today (eg. &date=last52&period=week will return an entry for each of the 52 weeks before this week). This is relative to the website timezone.
And it works like this when I apply it eg here: http://demo.piwik.org/?module=API&method=API.get&format=JSON&idSite=7&period=week&date=previous6 It seems to be only limited for CSV/TSV export as this returns an error see http://demo.piwik.org/?module=API&method=API.get&format=CSV&idSite=7&period=week&date=previous6 . It is failing here: https://github.com/piwik/piwik/blob/2.16.2-b2/core/DataTable/Renderer/Csv.php#L309 . I have issued a pull request in https://github.com/piwik/piwik/pull/10273 to fix it but I cannot promise it'll be merged as some other tests may fail.
Yeah, I know I'm pushing it to hard and over it's limit. ;)
I'm using last%month and last%20year for a long time now, but never for ranges. oh... and never on the 31st of a month, or the last week of march, because of the month calculation bug that exists in strtotime.
If you look at strtotime page that is referenced by the error page that shows up, a lot more 'magic keywords' are available. I was hoping it could be added without to much of a hassle.
To be able to use previous6 in months and weeks in csv export would be really helpful. and it would solve my issue, without the use of unsupported magic keywords.
After deploying the next beta/rc to demo, I will confirm this bug is fixed and close the issue then.
be aware that I did not provide a fix for this issue, only for the reported CSV issue