Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message
Date Format Converter

Date Format Converter Laravel Package

danharrin/date-format-converter

Convert date format strings between PHP, Moment.js, and other common tokens. Handy for keeping Laravel backends and JavaScript frontends in sync when parsing, formatting, or validating dates across different libraries and locales.

View on GitHub
Deep Wiki
Context7

Convert token-based date formats between standards.

Frequently asked questions about Date Format Converter
How do I convert a PHP date format like 'Y-m-d' to Moment.js format in Laravel using this package?
Use the package’s `convert()` method with the source and target formats. For example, `Converter::convert('Y-m-d', 'php', 'moment')` returns `YYYY-MM-DD`. Wrap it in a Laravel service or facade for cleaner usage. The package handles most common token mappings automatically.
Does this package work with Laravel 10 or newer? Are there Laravel-specific dependencies?
This package is framework-agnostic and works with any PHP 8.0+ project, including Laravel 10. It has no Laravel-specific dependencies, so it integrates seamlessly via Composer. Just autoload it via PSR-4 or wrap it in a Laravel service for convenience.
Can I use this for API request/response normalization in Laravel?
Yes. The package is lightweight and ideal for APIs. You can create middleware to normalize incoming date formats (e.g., convert `MM/DD/YYYY` to `YYYY-MM-DD` for storage) or format API responses consistently. Example middleware is provided in the docs.
What if my date format isn’t supported? Can I extend it?
The package covers common formats (PHP, Moment.js, date-fns, etc.), but you can extend it for custom tokens by subclassing the `Converter` class or adding custom mappings. Check the source code for the token registry to see how to add new rules.
How should I handle invalid date formats (e.g., 'INVALID')?
The package throws exceptions for invalid formats by default. You can catch these exceptions or configure it to return `null` or a fallback value. For production, log warnings or validate inputs before conversion to avoid runtime errors.
Is this better than using Carbon or IntlDateFormatter for format conversion?
This package is specialized for *format string conversion* (e.g., `Y-m-d` ↔ `MM/DD/YYYY`), while Carbon handles date math and parsing. Use Carbon for date operations and this package for format normalization. It’s lighter and avoids Carbon’s overhead if you only need token mapping.
Can I use this in a Laravel queue job or batch processing?
Absolutely. The package is stateless and thread-safe, making it ideal for queue jobs or batch processing. For large datasets, benchmark performance—it’s negligible for most use cases, but bulk conversions (e.g., 10K+ records) should be tested for edge cases.
Does it support locale-specific formats like 'dd.MM.yyyy' (German) or 'dd/MM/yyyy'?
The package supports basic locale-agnostic formats but may not cover all regional variations (e.g., German `TT.MM.JJJJ`). For full localization, combine it with PHP’s `IntlDateFormatter` or extend the token mappings. Test edge cases like separators or ordinal indicators.
How do I wrap this in a Laravel facade for easier use?
Register the package as a Laravel service in `config/services.php` and bind it to the container. Then create a facade (e.g., `DateFormatConverter`) to expose methods like `convert()`. Example code is provided in the docs, including a `DateHelper` class for reusable conversions.
What’s the maintenance status? Should I worry about breaking changes?
The package is MIT-licensed with a simple codebase and no active development since 2024. It’s low-risk for adoption, but monitor for updates if using it long-term. The design is stable, and breaking changes are unlikely unless new format standards emerge.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
hexters/coinpayment
rjcodes/rjcms
act-training/laravel-permissions-manager
alimarchal/laravel-chart-of-accounts
babenkoivan/elastic-scout-driver
mkwebdesign/filament-watchdog-v5
renatomarinho/laravel-page-speed
zedmagdy/filament-business-hours
renatovdemoura/blade-elements-ui
devgeek/beacon-admin
benjamin-rqt/data-watcher-bundle
atriumphp/atrium
sandermuller/package-boost-laravel
sandermuller/boost-skills
redaxo/core
yusufgenc/filament-api-forge
l3aro/rating-star-for-filament
leek/filament-subtenant-scope
anil/file-picker
broqit/fields-ai