Description
Describe the bug
I found this bug as I was working on #8522.
The dates used as filter that are passed to server are incorrect and this can lead to a misleading result.
The times displayed under the Date / Time
column are in the blog's timezone (can be set at wp-admin > Settings > General > Timezone).
When user chooses the date filter before and after, they expect to filter the date based on their local time (browser's time).
Currently, the filter dates will be passed to PHP in UTC (because of this). Then, WC_REST_Payments_Transactions_Controller::format_transaction_date_with_timestamp() will convert the dates before passing it to server. It will calculate the difference between store's timezone and user browser's timezone, which is incorrect. The server should receive the date in UTC.
To Reproduce
- Set blog timezone to be different from browser's timezone. wp-admin > Settings > General > Timezone.
- Set the date filter on the transaction list page, either before, after, or between.
- Debug the value of the filter dates that are passed to server. It should be the UTC of what is input by user, for example, if my timezone is UTC+7 and I choose
2024-09-01
and2024-09-03
, I will be expecting any data between2024-09-01 00:00:00
and2024-09-03 23:59:59
in UTC+7, which means2024-08-31 17:00:00
and2024-09-03 16:59:59
in UTC.
Actual behavior
The filter dates passed to server is UTC + (difference between browser's timezone and store's timezone).
Expected behavior
The filter dates passed to server should be in UTC.