@tsteur opened this Issue on February 24th 2016 Member

See https://github.com/piwik/piwik/issues/9798#issuecomment-187644739

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):

@oleg-sh commented on February 24th 2016

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.

@tsteur commented on February 24th 2016 Member

For RSS it's normal, switch format to XML and they bug is still the same

@RMastop commented on July 5th 2016 Contributor

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: module=API&method=API.get&format=CSV&idSite=37&period=week&date=previous6
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.

@tsteur commented on July 5th 2016 Member

FYI: AFAIK last%20month and last%20year are not supported formats. See http://developer.piwik.org/api-reference/reporting-api under date. As magic keywords only today and yesterday are supported as well as eg last6 and previous6.

There it says re previous6:

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.

@RMastop commented on July 5th 2016 Contributor

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.

@mattab commented on July 12th 2016 Member

After deploying the next beta/rc to demo, I will confirm this bug is fixed and close the issue then.

@tsteur commented on July 12th 2016 Member

be aware that I did not provide a fix for this issue, only for the reported CSV issue

@mstenz commented on February 22nd 2018

please note that this similar issue also happen when you have set the time to monthly and then click from the "All Websites" on a Website link. As this is made from the UI automatically it should work without error.

Powered by GitHub Issue Mirror