Download the PHP package erag/laravel-datetime-format without Composer
On this page you can find all versions of the php package erag/laravel-datetime-format. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package laravel-datetime-format
Laravel DateTime Format
A powerful Laravel package for centralized and consistent date/time formatting across your application. Automatically format Eloquent model dates, API responses, Blade output, and Carbon instances without repeating manual ->format(...) calls everywhere.
Key Features π₯
- π€ Automatic Eloquent model datetime formatting
- π§ Centralized datetime formatter service
- π§© Custom cast support with
FormattedDateTimeCast - π¨ Blade directive support via
@dateTimeFormat(...),@datetime(...),@dateFormat(...), and@timeFormat(...) - β±οΈ Carbon macro support using
toConfiguredFormat() - π¦ API resource helper macros
- π Timezone and locale support
- π§± Laravel
10,11,12, and13support - β
PHP
8.2+support
Install π
Config βοΈ
Published file: config/datetime-format.php
What timezone and locale do π
timezone: defines the timezone used for formatted output.
Example: the input can be UTC, but output can be converted toAsia/Kolkata.locale: sets Carbonβs language/context before formatting.
This is useful when using month/day names, such as28 May 2026or localized month labels.
Quick Understanding (Before vs After) π
Without package (common output):
With package + trait:
Usage
1) Model Auto Format (Recommended) π€
By default, every formatted date uses the global package config:
datetime-format.formatdatetime-format.timezonedatetime-format.locale
Controller:
Response example:
1.1) Different format per attribute π€
Use formattedDateAttributes() when you want different output formats on the same model:
Example output:
1.2) Different format and timezone per attribute π
Use $formattedDate when a field needs additional options like timezone or locale:
This is enough by itself. You do not need to repeat the same fields in formattedDateAttributes().
Example output:
1.3) Real User.php example β
Rule of thumb:
- use default package config when all date fields should look the same
- use
formattedDateAttributes()for per-attribute formats - use
$formattedDatefor per-attributeformat,timezone, andlocale - prefer one approach per field to keep model code short and readable
If your custom format is date-only, time will not be included:
Output:
2) Custom Cast (When you only want specific columns formatted) π§©
Example output:
3) Blade Directive π¨
Rendered output:
4) Formatter Service π§
Response example:
5) Facade Usage π οΈ
6) Carbon Macro β±οΈ
7) API Resource Macro π¦
Resource output example:
Real Demo Style Response β
If you want to see mixed output (service + blade + model):
All versions of laravel-datetime-format with dependencies
illuminate/contracts Version ^10.0|^11.0|^12.0|^13.0
illuminate/database Version ^10.0|^11.0|^12.0|^13.0
illuminate/support Version ^10.0|^11.0|^12.0|^13.0
nesbot/carbon Version ^2.72|^3.0