Skip to content

Simple wrapper around DateTime to allow strict datetime validation

License

Notifications You must be signed in to change notification settings

tomasfejfar/datetime-strict

Repository files navigation

datetime-strict

Build Status Coverage Status Total Downloads Latest Version on Packagist Average time to resolve an issue Percentage of issues still open

Simple wrapper around DateTime to allow strict datetime validation

Install via Composer

composer require tomasfejfar/datetime-strict

Usage

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.

Changelog

Changes can be found in each tag's annotation

Rules for contributing

  • 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!

About

Simple wrapper around DateTime to allow strict datetime validation

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages