tomasfejfar/datetime-strict

Simple DateTime wrapper allowing strict date and time validation

0.2 2016-12-06 14:11 UTC

This package is auto-updated.

Last update: 2024-12-06 10:17:26 UTC


README

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!