Simple wrapper around DateTime to allow strict datetime validation
composer require tomasfejfar/datetime-strict
use TomasFejfar\DateTime\DateTimeStrict;
use TomasFejfar\DateTime\StrictFormatException;
try {
$date = DateTimeStrict::createFromFormat('Y-m-d H:i:s', '2001-33-05 13:35:08');
} catch (StrictFormatException $e) {
$warnings = $e->getWarnings();
$errors = $e->getErrors();
}
Usage for immutable variant is the same, just use DateTimeImmutableStrict::createFromFormat()
instead.
Changes can be found in each tag's annotation
- 1 PR per feature
- PR with tests are more likely to be merged
- tests and coding standard must pass
composer test
composer phpcs
Happy coding!