- How do I install techouse/intl-date-time in a Laravel app?
- Install it with Composer by running composer require techouse/intl-date-time from your Laravel project root. Laravel's package auto-discovery registers the service provider, so no manual provider entry is needed. Make sure the PHP Intl extension is enabled on your runtime before you rely on formatting.
- Does it format Carbon instances, native DateTime objects, and timestamps?
- Yes. The package accepts Carbon instances, native DateTime objects, and raw timestamp values, so you can format dates from Eloquent casts, request input, or legacy code through the same API. Every value is rendered with PHP's IntlDateFormatter using an ICU pattern.
- How do I format a date using an ICU pattern with this package?
- Pass an ICU date or time pattern to the facade or helper and the package formats the value according to the configured locale and timezone. ICU patterns let you control month and weekday names, day-month ordering, and 12-hour versus 24-hour output. The same pattern produces different but correct output for each locale.
- How do I set the default locale and timezone for formatting?
- The package reads your application's configured locale and timezone by default, so most apps need no extra setup. If you need package-level overrides, publish its configuration file and set the default locale and timezone there. This keeps display formatting aligned with the rest of your app's localization settings.
- Can I use it directly in Blade templates?
- Yes, the package exposes Blade directives in addition to the facade and helper, so you can format dates directly in your views. This keeps templates free of hard-coded PHP date format strings. For testability you may still prefer formatting in a view model or presenter.
- What Laravel and PHP versions does it support?
- The package targets modern Laravel releases on current PHP versions and requires the PHP Intl extension. Exact constraints are pinned in its composer.json, so compare that file against your application's Laravel and PHP versions before installing. There are no migration or database requirements.
- Does it provide validation rules for localized date input?
- Yes. The package includes validation rules intended for localized date input, letting you accept dates in a user's locale-specific format and validate them before storage. Pair them with a datetime cast and store values in a consistent format such as ISO-8601 in UTC. Treat any locale-formatted string coming from a client as presentation only.
- How is it different from Carbon's formatting or PHP's date() function?
- PHP's date() and Carbon's default formatting use fixed format characters, so ordering and names stay the same regardless of locale. This package uses ICU patterns through IntlDateFormatter, meaning day-month ordering, month and weekday names, and 12/24-hour conventions follow the target locale. That makes it a better fit for apps serving users across multiple locales.
- What happens if the PHP Intl extension is not installed?
- The package is a lightweight wrapper around PHP's Intl extension, so that extension must be installed and enabled; it is a hard dependency, not a soft one. Without it, IntlDateFormatter is unavailable and formatting calls will fail. Verify the extension on your runtime image and in CI as part of setup.
- Is it suitable for production, and how should timezones be stored?
- It is a small, stateless formatting layer with no migrations or data model changes, so production risk stays low when versions are pinned. Store dates in UTC in ISO-8601 and format only at display time to avoid off-by-one-day errors and daylight-saving drift. Because it is maintained by a single author, review repository activity and lock the version in composer.lock like any other dependency.