apie/dateformat-to-regex
Converts PHP date() format strings into “simple” regular expressions for validating date/time strings. Generates regex that matches the format pattern (not full calendar validation, e.g., may accept 30 February). Includes a static DateFormatToRegex::formatToRegex() helper.
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
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.
<?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));
How can I help you explore Laravel packages today?