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

Post Date block: Different display when site & user timezone don't match #39984

Open
ryelle opened this issue Apr 1, 2022 · 1 comment
Open
Labels
[Block] Post Date Affects the Post Date Block [Type] Bug An existing feature does not function as intended

Comments

@ryelle
Copy link
Contributor

ryelle commented Apr 1, 2022

Description

I'm in EDT (UTC-4), and I created a post at 12pm. My site is in PDT (UTC-7), so it saved the post as being created at 9:00am PDT. I have a set of post date blocks using different date formats.

In the database, it has

post_date: 2022-04-01 09:00:00
post_date_gmt: 2022-04-01 16:00:00

On the frontend of the site, the Post Date block shows

  • ✅ Publish Date (with timezone): Apr 1, 2022 — 9:00 am PDT
  • ❌ Publish Date (timestamp): 1648803600
  • ✅ Publish Date (ISO 8601): 2022-04-01T09:00:00-07:00

In the site editor, all three formats show different results

  • ❌ Publish Date (with timezone): Apr 1, 2022 — 6:00 am PDT
  • ❌ Publish Date (timestamp): 1648818000
  • ❌ Publish Date (ISO 8601): 2022-04-01T06:00:00-07:00

The timestamp should be 1648828800.

Step-by-step reproduction instructions

  1. Set your site to a different timezone than your current TZ
  2. Write a post, make note of the publish time
  3. Add a Post Date block either to the post, or in the site editor. Use custom format M j, Y — g:i a T to see the full date with timezone.

Screenshots, screen recording, code snippet

Block code used to test, sets up a group with 3 date blocks using different formats.

<!-- wp:group {"style":{"color":{"background":"#ced9c9"}}} -->
<div class="wp-block-group has-background" style="background-color:#ced9c9"><!-- wp:group {"style":{"spacing":{"margin":{"bottom":"12px"}}},"layout":{"type":"flex"}} -->
<div class="wp-block-group" style="margin-bottom:12px"><!-- wp:paragraph -->
<p>Publish Date (with timezone)</p>
<!-- /wp:paragraph -->

<!-- wp:post-date {"format":"M j, Y — g:i a T"} /--></div>
<!-- /wp:group -->

<!-- wp:group {"layout":{"type":"flex"}} -->
<div class="wp-block-group"><!-- wp:paragraph -->
<p>Publish Date (timestamp)</p>
<!-- /wp:paragraph -->

<!-- wp:post-date {"format":"U"} /--></div>
<!-- /wp:group -->

<!-- wp:group {"layout":{"type":"flex"}} -->
<div class="wp-block-group"><!-- wp:paragraph -->
<p>Publish Date (ISO 8601)</p>
<!-- /wp:paragraph -->

<!-- wp:post-date {"format":"c"} /--></div>
<!-- /wp:group --></div>
<!-- /wp:group -->

Environment info

  • Gutenberg trunk (12.9)
  • WP 5.9.2-alpha-52803
  • Theme: Emptytheme
  • No other plugins active

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

@ryelle ryelle added the [Block] Post Date Affects the Post Date Block label Apr 1, 2022
@carolinan
Copy link
Contributor

I am able to reproduce this.

@jordesign jordesign added the [Type] Bug An existing feature does not function as intended label Sep 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Block] Post Date Affects the Post Date Block [Type] Bug An existing feature does not function as intended
Projects
None yet
Development

No branches or pull requests

3 participants