curly_sanders / carbon-normalizer
Normalizes to (and from) Carbon and native DateTime objects
v0.3.1
2025-02-11 15:11 UTC
Requires
- nesbot/carbon: ^2.0 || ^3.0
- symfony/property-info: ^5.0 || ^6.0 || ^7.0
- symfony/serializer: ^5.0 || ^6.0 || ^7.0
Requires (Dev)
- illuminate/support: ^8.0
- phpunit/phpunit: ^10.0
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.