PRG pattern and datetime timezone query with FriendsOfCake/Search

/* Controller */
public function initialize(): void
   $this->loadComponent('Search.Search', ['actions' => ['test']]);

public function test()
    if (empty($this->request->getQuery('fecha')))
        return $this->redirect(['?' => ['fecha' => 'now']]);

    /* get some data and send it to the view */

/* Template */
<?= $this->Form->create(null, ['valueSources' => 'query']) ?>
<?= $this->Form->dateTime('fecha'); ?>
<?= $this->Form->button('search') ?>
<?= $this->Form->end() ?>

I’m using the FriendsOfCake/Search plugin and this is my code to show some data.

Now, I want to show the datetime input in the user timezone, so I added the option:

['timezone' => $this->Identity->get('timezone')]

After that change, every time I submit the form, the form input recedes 3 hours since I’m currently on GMT-3.

How can I fix this? I was looking towards the DateTimeMiddleware but I can’t come up with a solution.

Do you mean in address bar? There is a date-time string format with time zone coded in, maybe this approach will help you. I don;t fully understand what do you need, but if you want to use in same place (let’s say input field) two different datetimes without enabling to choose / edit one it can be difficult and misleading to user.

Thanks for your response, I updated the initial question to make it more clear.

Yes, I meant the address bar. I think the query should be expressed as UTC since the user can share the URL with another user who has another timezone.

try to debug this query and watch how this is send. In cake 3 date-times widget send separately day, month, year, minute, hour and it was not time zone related, what digits user sets, they was send. I’m not familiar with cake 4 and this middle plugin.
But you can add in controller


maybe there should be getRequest() etc.
and check format (or use debug bar->request).
If you want that user enters time in his tz and send it to server always as UTC use javascript and convert it on form submit.