Skip to content

[Validator] Fix a valid Date and Time constraint format #17746

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

Merged
merged 1 commit into from
Mar 22, 2023

Conversation

adnen-chouibi
Copy link
Contributor

@adnen-chouibi adnen-chouibi commented Jan 14, 2023

I noticed that the date and time format specified at the start of the documentation is not correct, it should be Y-m-d for Date and H:i:s for Time instead of YYYY-MM-DD and HH:MM:SS

@adnen-chouibi adnen-chouibi requested a review from xabbuh as a code owner January 14, 2023 19:14
@carsonbot carsonbot added this to the 5.4 milestone Jan 14, 2023
@xabbuh
Copy link
Member

xabbuh commented Jan 16, 2023

I think the previous formats were meant to be human-readable and not something that you could pass to date() or DateTimeInterface::format(). And I think not having the reader to know all the format options is a good thing. But can we somehow end up with something more clear than we have right now to avoid confusion?

@adnen-chouibi
Copy link
Contributor Author

The Date constraint accepts only one format as mentioned in the example, $birthday it should be a string "Y-m-d" formatted value.
There is no other option to use it other than H:i:s for Time() and Y-m-d for Date().

@carsonbot carsonbot changed the title Fix a valid Date and Time constraint format [Validator] Fix a valid Date and Time constraint format Mar 22, 2023
@javiereguiluz
Copy link
Member

In the code examples we mentioned that those were the only valid format ... but I agree that we could be explicit about this in the explanation too. I added some real example too in case any reader needs help with the PHP date formatting letters.

@adnen-chouibi thanks and congrats on your first Symfony Docs contribution 🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants