Date Comparison Fails with Calendar Selection - 500 Error and Empty compareDates Parameter

Hi Matomo community,

I’m running a self-hosted Matomo instance, and I’ve been using it for about a year now. I’m currently on the latest version, Matomo 5.3.1.

Everything has been working great, and all statistics are collected normally. However, I’m encountering a specific issue with the date comparison feature, specifically when using “User Defined” comparison with calendar date selection.

Problem Description:

The issue occurs when I try to compare data for a specific date range using the “User Defined” option and selecting dates directly from the calendar.

Scenario: Let’s say I want to compare data for March 25th, 2025 with March 7th, 2025.

Steps to reproduce:

  1. Go to any report in Matomo.
  2. Select the specific date at the top (e.g., currently showing “2025-03-21”).
  3. In the date picker popup, choose “Compare to” and then select "User Defined.
  4. Select specific date (compare date)
  5. Click the “Apply” button.

Expected Result: The report should load, comparing the data for the selected date (March 25th) with the user-defined date (March 7th).

Actual Result: I get an error message and the report fails to load.

  1. Browser Console Error (from the previous response):

POST https://...../index.php?date=2025-03-07&forceView=1&viewDataTable=sparklines&module=VisitsSummary&action=get&disableLink=0&widget=1&comparePeriods%5B%5D=range&compareDates%5B%5D=%2C&idSite=7&period=day 500 (Internal Server Error)

Notice the compareDates%5B%5D=%2C part in the POST request. It seems the compareDates parameter is being sent with just a comma, indicating that the date is not being properly passed when selected from the calendar.*

  1. On the screen error.
Valid date format: YYYY-MM-DD, or 'today' or 'yesterday' or any keyword supported by the strtotime function (see http://php.net/strtotime for details): false

I’ve already checked my PHP code, but I haven’t been able to find any obvious issues related to date handling.

Can someone tell me how do i fix this?

Thank you.