rtuin/carbon-normalizer

Normalizes to (and from) Carbon and native DateTime objects

Installs: 47 270

Dependents: 0

Suggesters: 0

Security: 0

Stars: 2

Watchers: 1

Forks: 4

Open Issues: 1

pkg:composer/rtuin/carbon-normalizer

v0.2.0 2023-05-02 22:17 UTC

This package is auto-updated.

Last update: 2025-10-01 00:13:18 UTC


README

This is a Normalizer for the Symfony Serializer package that supports normalizing to and from Carbon, CarbonImmutable, Illuminate\Support\Carbon, DateTime and DateTimeImmutable.

Usage example

$normalizer = new \Rtuin\Normalizer\CarbonDateTimeNormalizer();

$normalized = $normalizer->normalize(\Carbon\CarbonImmutable::now());
// $normalized is now a string '2019-05-28T07:25:00+02:00'


$result = $normalizer->denormalize('2019-05-28T07:25:00+02:00', CarbonImmutable::class);
// $result is now a CarbonImmutable instance

License

The MIT License (MIT). Please see License File for more information.