apie / dateformat-to-regex
Composer package of the apie library: dateformat to regex
Installs: 1 989
Dependents: 1
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 0
Requires
- php: >=8.1
- apie/core: dev-main
Requires (Dev)
- phpspec/prophecy-phpunit: ^2.0
- phpunit/phpunit: ^9.5
This package is auto-updated.
Last update: 2024-12-26 08:10:46 UTC
README
dateformat-to-regex
This package is part of the Apie library. The code is maintained in a monorepo, so PR's need to be sent to the monorepo
Documentation
This package converts PHP date format strings into regular expressions. Right now it will create the 'simple' regular expression. So it will validate 30 february as a valid date.
Usage
<?php use Apie\DateformatToRegex\DateFormatToRegex; $dateFormat = DateTime::ATOM; $regularExpression = DateFormatToRegex::formatToRegex($dateFormat); $dateString = '2020-01-28T16:22:37-07:00'; // echos 1 as the regular expression matches the date string. var_dump(preg_match($regularExpression, $dateString));