0

I use Magento 2.4.1. I have a problem with admin grid.

In my edit form, I set Booking From is: 18:30:00 and Booking To is: 19:30:00 at timezone GMT+7.

When I save, from, to are saved correctly to database, but in my grid, From, To is shown like image below: enter image description here

I have no idea to solve it, please help me. Thanks a lot and sorry for my English.

0

Could it be somewhat related to the Admin locale setting? enter image description here

1
  • I changed, but not work :( – Simpa407 Mar 4 at 3:48
0

Change the timezone in the locale settings for the default scope - https://docs.magento.com/user-guide/stores/locale-options.html


Later edit

It just occurred to me that this has to do with the way the code is written and not a matter of configuration. Normally, when you add items to the database, the time added on the record should be in UTC time and not relative to any timezone.

This should be done this way so that it could accommodate any number of timezones in the areas where the data is visualized (admin or frontend).

You also mentioned

In my edit form, I set Booking From is: 18:30:00 and Booking To is: 19:30:00 at timezone GMT+7. When I save, from, to are saved correctly to database (...)

If the code was written properly, in the database, you should see the time like this:

booking from: 11:30
booking to: 12:30

and not the actual times 18:30 and 19h30. The conversion to these times to your timezones should be done only when reading the data, not when writing it to the database.

So you need to change the code which adds the records to the database and make sure it adds the time relative to UTC standard.

2
  • Thank you, but it's not working :( – Simpa407 Mar 2 at 12:00
  • please check the update on my answer. i think i know what's going on in there :) – Diana Botean Mar 4 at 12:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.