nesbot/carbon
Carbon is a PHP DateTime extension that makes working with dates and times simple and readable. Parse, format, compare, add/subtract intervals, handle timezones and localization, and use fluent, human-friendly helpers for common date tasks.
DateTime. Its API aligns with Laravel’s conventions (e.g., now(), today() helpers) and extends them with fluent, expressive methods.copy()->addDays() vs. $date->addDays()), reducing side effects in complex workflows.translatedFormat(), diffForHumans()) make it ideal for global applications.composer require nesbot/carbon:^3.0 is trivial.setTestNow() and freezeTime() simplify time-sensitive tests (critical for Laravel’s test suite).Carbon::macro() (e.g., isBusinessDay()) without core modifications.resetMessages optimization), but edge cases (e.g., recursive diffs) may persist in legacy code.timezone('UTC')->isSameDay()).setLocale() vs. Laravel’s app()->setLocale().copy()) to avoid side effects?Carbon::setTestNow()) sufficient, or are mocks needed for complex scenarios?DateTime?isHoliday())?now(), parse()) and Eloquent integration.whereDate(), orderBy()).new DateTime() with Carbon\Carbon::create() or now().DateTime instances in services/repositories to use Carbon’s fluent API.AppServiceProvider (e.g., Carbon::setDefaultLocale()).app()->getLocale() for dynamic locales.DateTime::setTime() with Carbon::setTestNow().copy()->addDays()).DateTime logic via deprecation warnings.spatie/laravel-activitylog or laravel-excel (most use Carbon internally).moment.php or php-date alternatives.Carbon::instance($dateTime) to wrap existing DateTime objects.DateTimeInterface) for gradual replacement.now(), parse(), and format().translatedFormat()).Carbon::setTestNow().composer why-not nesbot/carbon:^3.0 to check for conflicts.dump() and debug() methods integrate with Laravel’s debugbar.Carbon::getLastErrors() to diagnose parsing/formatting issues.php-carbon) provide broad support.DateTime via Carbon::instance() or Carbon::createFromDateTime().DateTime for high-throughput operations (e.g., cron jobs processing 10k+ events).resetMessages() memory consumption (fixed in v3.10.2).translatedFormat() with unsupported locale).en_US fallback).America/New_York vs. EST).timezone('America/New_York')).parse('invalid')).tryParse() or validate inputs with Carbon::isValid().Carbon::serialize()/unserialize() for complex objects.now()->addDays(5)->format('Y-m-d')).translatedFormat(), setLocale()).setTestNow()).How can I help you explore Laravel packages today?