-
Notifications
You must be signed in to change notification settings - Fork 4.6k
Implement format for datetime #73924
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
Conversation
|
#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, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
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
|
Flaky tests detected in df5fedc. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/20165831866
|
df5fedc to
2e1226f
Compare
|
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 If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message. To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
|
I've rebased this PR from trunk, so it can be merged independently. |
jorgefilipecosta
left a comment
There was a problem hiding this 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 👍
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. |


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?
formatwithdatetimeandweekStartsOnprops.Testing Instructions
Visit the datetime field type storybook:
Screen.Recording.2025-12-11.at.19.03.12.mov