Skip to content

Conversation

@oandregal
Copy link
Member

Closes #73154
Depends on #73922

What?

Implements format for datetime.

Why?

It's the last of the formats we need to implement from #73154

How?

  • Adds a format with datetime and weekStartsOn props.

Testing Instructions

Visit the datetime field type storybook:

Screen.Recording.2025-12-11.at.19.03.12.mov

@oandregal oandregal self-assigned this Dec 11, 2025
@oandregal oandregal added [Type] Feature New feature to highlight in changelogs. [Feature] DataViews Work surrounding upgrading and evolving views in the site editor and beyond labels Dec 11, 2025
@oandregal
Copy link
Member Author

#73922 needs to land first. I'll rebase and add the changelog when that's done.

import render from './utils/render-default';

const format = {
datetime: getSettings().formats.datetime,
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's an extra space between the hour and the minutes coming from this default:

Screenshot 2025-12-11 at 19 06 03

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The default is defined here:

formats: {
		time: 'g: i a',
		date: 'F j, Y',
		datetime: 'F j, Y g: i a',
		datetimeAbbreviated: 'M j, Y g: i a',
	},

Note how there's a space after the colon and before the minutes: g: i (reference PHP's datetime format).

I'm a bit confused about why this is setup the way it is. I can't think of a reason why the minutes would have a space before the hour. The only plausible explanation is that this was just a dormant bug because nobody actually used these formats in the years since? I've fixed it at 4c730f6

@oandregal oandregal mentioned this pull request Dec 11, 2025
4 tasks
@github-actions
Copy link

github-actions bot commented Dec 11, 2025

Flaky tests detected in df5fedc.
Some tests passed with failed attempts. The failures may not be related to this commit but are still reported for visibility. See the documentation for more information.

🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/20165831866
📝 Reported issues:

@oandregal oandregal changed the base branch from update/remove-type-check-filter-and-controls to trunk December 16, 2025 10:01
@oandregal oandregal marked this pull request as ready for review December 16, 2025 10:01
@github-actions
Copy link

github-actions bot commented Dec 16, 2025

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Co-authored-by: oandregal <[email protected]>
Co-authored-by: jorgefilipecosta <[email protected]>
Co-authored-by: ntsekouras <[email protected]>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@oandregal
Copy link
Member Author

I've rebased this PR from trunk, so it can be merged independently.

@jorgefilipecosta
Copy link
Member

Non blocking, but should the form input bellow the calendar also follow the applied format?:
Screenshot 2025-12-18 at 11 33 12

Copy link
Member

@jorgefilipecosta jorgefilipecosta left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Worked well on the tests I did 👍

@github-actions github-actions bot added [Package] Date /packages/date [Package] DataViews /packages/dataviews labels Dec 18, 2025
@oandregal
Copy link
Member Author

Non blocking, but should the form input bellow the calendar also follow the applied format?:

I see how in some situations this would be handy. For example, dd/mm/yyyy vs mm/dd/yyyy. However, the date format can be anything and there's no a 1:1 match to the input field, so I'd rather leave the input field as it is.

@oandregal oandregal enabled auto-merge (squash) December 18, 2025 12:04
@oandregal oandregal merged commit 863dd53 into trunk Dec 18, 2025
56 of 60 checks passed
@oandregal oandregal deleted the add/format-datetime branch December 18, 2025 12:46
@github-actions github-actions bot added this to the Gutenberg 22.4 milestone Dec 18, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[Feature] DataViews Work surrounding upgrading and evolving views in the site editor and beyond [Package] DataViews /packages/dataviews [Package] Date /packages/date [Type] Feature New feature to highlight in changelogs.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Field API: display formats

3 participants