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

Date and datetime string validator #602

Closed
samdark opened this issue May 2, 2023 · 2 comments · Fixed by #646
Closed

Date and datetime string validator #602

samdark opened this issue May 2, 2023 · 2 comments · Fixed by #646
Labels
type:feature New feature

Comments

@samdark
Copy link
Member

samdark commented May 2, 2023

DateRule validates a string value that represents a date. DateTimeRule validates a string value that represents date and time.

Options

format, see DateTime::createFromFormat()

For Date default could be 'Y-m-d', for DateTime it could be Y-m-d H:i:s.

Implementation

Use \DateTime::createFromFormat() then \DateTime::getLastErrors() or regex + validating if date and time are valid.

@samdark samdark added the type:feature New feature label May 2, 2023
@samdark samdark added this to the 1.1.0 milestone May 2, 2023
@samdark samdark removed this from the 1.1.0 milestone May 2, 2023
@Gerych1984
Copy link

Gerych1984 commented Oct 30, 2023

I wrote a similar one for my needs (need to fix namespaces). It may be useful with a little tweaking
DateTime.zip

@samdark samdark linked a pull request Jan 12, 2024 that will close this issue
samdark pushed a commit that referenced this issue Jan 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type:feature New feature
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants