Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Inconsistency] Time Inconsistencies When Local and Site Timezones Don’t Match #67982

Open
2 of 6 tasks
sarthaknagoshe2002 opened this issue Dec 13, 2024 · 1 comment
Open
2 of 6 tasks
Labels
Internationalization (i18n) Issues or PRs related to internationalization efforts [Type] Bug An existing feature does not function as intended

Comments

@sarthaknagoshe2002
Copy link
Contributor

sarthaknagoshe2002 commented Dec 13, 2024

Description

Discovered this issue while working on #67751
All blocks using the <time> tag currently have an incorrect datetime attribute when the device's timezone differs from the timezone set in the site settings.

For example, if the device timezone is UTC+5:30, the datetime picker converts the selected time to UTC+0, as it displays UTC+0 alongside the picker. However, in most blocks, the time selected in the picker is then formatted using dateI18n(), which assumes the input is UTC+5:30. This results in an incorrect conversion to UTC-5:30 instead of the intended UTC+0.

Step-by-step reproduction instructions

  1. Set timezone to a different timezone than your device's timezone
  2. Add a block which uses <time> tag
  3. Check your device time ( In this case ~8pm )
  4. The time in datetime picker converts it to UTC+0 since the site timezone is UTC+0 ( in this case ~2:30pm )
  5. check the datetime attribute which again changes the timezone ( In this case ~9am )

Screenshots, screen recording, code snippet

time.mov

Environment info

No response

Please confirm that you have searched existing issues in the repo.

  • Yes

Please confirm that you have tested with all plugins deactivated except Gutenberg.

  • Yes

Please confirm which theme type you used for testing.

  • Block
  • Classic
  • Hybrid (e.g. classic with theme.json)
  • Not sure
@sarthaknagoshe2002 sarthaknagoshe2002 added the [Type] Bug An existing feature does not function as intended label Dec 13, 2024
@sarthaknagoshe2002
Copy link
Contributor Author

This issue can be resolved by passing the timezone reported by the datetime picker, ensuring dateI18n() recognizes the input as already UTC+0, eliminating the need for further conversion.

@ellatrix ellatrix added the Internationalization (i18n) Issues or PRs related to internationalization efforts label Dec 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Internationalization (i18n) Issues or PRs related to internationalization efforts [Type] Bug An existing feature does not function as intended
Projects
None yet
Development

No branches or pull requests

2 participants