techouse/intl-date-time
最新稳定版本:v1.7.0
Composer 安装命令:
composer require techouse/intl-date-time
包简介
International datepicker field for Laravel Nova.
README 文档
README
International datepicker for Laravel Nova
Apply localisation in 71 different locales to Laravel Nova's default DateTime field that currently doesn't support localisation out of the box.
Installation
You can install the package in to a Laravel app that uses Nova via composer:
composer require techouse/intl-date-time
Usage
The API is adapted from Nova's default DateTime Field.
The module itself offers a few optional configurations:
- locale - OPTIONAL - Set the module's locale. If you do not it will automatically use your app's
config('app.locale'). If you manually define an unsupported locale it will throw an Exception! - dateFormat - OPTIONAL - Set a date format. If you do not provide it the module will automatically use the appropriate locale's date format. The format must be MomentJS compatible!
- timeFormat - OPTIONAL - Set a time format. The format must be MomentJS compatible! If you manually define an unsupported time format it will throw an Exception!
- minDate - OPTIONAL - Set a minimum/earliest date (inclusively) allowed for selection. Has to be an instance of
\DateTimeorCarbon\Carbon. Defaults tonull. - maxDate - OPTIONAL - Set a maximum/latest date (inclusively) allowed for selection. Has to be an instance of
\DateTimeorCarbon\Carbon. Defaults tonull. - placeholder - OPTIONAL - Set a placeholder. If you do not want a placeholder set it to
false. - errorMessage - OPTIONAL - Set a custom error message in case of an invalid date format. If you do not set it it will display an error message in the current locale.
- errorMessageLocale - OPTIONAL - Set a custom error message locale. If not set it equals the set
localeor your app'sconfig('app.locale'). If you manually define an unsupported locale it will throw an Exception! Here is the list of all supported locales. - hideUserTimeZone - OPTIONAL - When applied hides the user time zone next to the form field. Default is
false. - withShortcutButtons - OPTIONAL - When applied shows the user 3 shortcut buttons for 'yesterday, 'today' and 'tomorrow' below the calendar. The buttons are all in English and in order to translate them please edit your language JSON file in the directory
resources/lang/vendor/nova. - withTime - OPTIONAL - Shortcut for displaying the full locale time, e.g. HH:mm:ss. NOTE: The timeFormat option has precedence over withTime.
- withTimeShort - OPTIONAL - Shortcut for displaying the short locale time, e.g. HH:mm. NOTE: The timeFormat option has precedence over withTimeShort.
- userTimeZone - OPTIONAL - Define custom Timezone for specific field - by default Nova.config.userTimezone is used.
Simply use IntlDateTime class instead of DateTime directly or alias it like the example below so you won't have to refactor too much existing code.
<?php namespace App\Nova; use Carbon\Carbon; use Illuminate\Http\Request; use Techouse\IntlDateTime\IntlDateTime as DateTime; class User extends Resource { /** * This is how you use and configure this module */ public function fields(Request $request) { return [ DateTime::make(__('Updated at'), 'updated_at') /** * The module automatically uses your app's locale * from config('app.locale'), however you can manually * override this by setting it like this. * * IMPORTANT: Check the list of supported locales below in this readme! * * NOTE: If the automatic locale is not supported by MomentJS * the module defaults to 'en-gb' (British English). */ ->locale('sl'), DateTime::make(__('Created at'), 'created_at') /** * You can optionally set a custom DATE format. * * It has to be compatible with MomentJS!!! * https://momentjs.com/docs/#/displaying/format/ */ ->dateFormat('DD.MM.YYYY'), DateTime::make(__('Deleted at'), 'deleted_at') /** * You can optionally set a custom TIME format * * It has to be compatible with MomentJS!!! * https://momentjs.com/docs/#/displaying/format/ */ ->timeFormat('HH:mm:ss'), DateTime::make(__('Packaged on'), 'packaged_on') /** * You can optionally set a placeholder, otherwise * it will default to your timezone's date format */ ->placeholder('DD.MM.LLLL'), DateTime::make(__('Shipped on'), 'shipped_on') /** * You can disable the placeholder by setting it to false */ ->placeholder(false), DateTime::make(__('Birthday'), 'birthday') /** * You can override the default date invalid error message */ ->errorMessage("I don't think you were born on that day mate :D"), DateTime::make(__('Day of graduation'), 'graduated_on') /** * Unless you override the error message locale it equals the locale setting */ ->errorMessageLocale('de'), DateTime::make(__('Takes place at'), 'takes_place_at') /** * Set a minimum/earliest date (inclusively) allowed for selection. */ ->minDate(Carbon::parse('1990-05-30')) /** * Set a maximum/latest date (inclusively) allowed for selection. */ ->maxDate(Carbon::today()), DateTime::make(__('Day you got married'), 'day_you_got_married') /** * Hide the user time zone next to the form input field. */ ->hideUserTimeZone(), DateTime::make(__('Date of travel'), 'date_of_travel') /** * Display shortcut buttons for "yesterday", "today" and "tomorrow". * Translate them in your language's JSON file located in resources/lang/vendor/nova. */ ->withShortcutButtons(), DateTime::make(__('Time of arrival'), 'time_of_arrival') /** * Shortcut for displaying the full locale time, e.g. HH:mm:ss. * * NOTE: The timeFormat option has precedence over withTime. */ ->withTime(), DateTime::make(__('Time of reservation'), 'time_of_reservation') /** * Shortcut for displaying the short locale time, e.g. HH:mm. * * NOTE: The timeFormat option has precedence over withTimeShort. */ ->withTimeShort(), DateTime::make(__('Time of reservation'), 'deleted_at') /** * Set default hour of time selector */ ->defaultHour(9), DateTime::make(__('Time of reservation'), 'uploaded_at') /** * Set default minute of time selector */ ->defaultMinute(30), ]; } /** * The rest of the Resource ... bla bla bla :) */ }
Programmed filling
Like many Laravel Nova Fields, this field implement the programmed filling. You can emit a Laravel Nova javascript event in order to fill the field in the update form.
Nova.$emit('my-field-name-value', '29/06/1998')
Please make sure that the value emitted correspond to your local date.
List of supported locales
This module supports only locales that are SUPPORTED BY BOTH MomentJS AND Flatpickr!
The 71 locales that are currently supported are:
| Language | locale |
|---|---|
| Albanian | sq |
| Arabic | ar |
| Azerbaijani | az |
| Bangla | bn |
| Belarusian | be |
| Bosnian | bs |
| Bulgarian | bg |
| Burmese | my |
| Catalan | ca |
| Chinese (China) | zh-cn |
| Chinese (Hong Kong) | zh-hk |
| Chinese (Taiwan) | zh-tw |
| Croatian | hr |
| Czech | cs |
| Danish | da |
| Dutch | nl |
| English | en |
| English (Australia) | en-au |
| English (Canada) | en-ca |
| English (Ireland) | en-ie |
| English (New Zealand) | en-nz |
| English (United Kingdom) | en-gb |
| Esperanto | eo |
| Estonian | et |
| Faroese | fo |
| Finnish | fi |
| French | fr |
| French (Canada) | fr-ca |
| French (Switzerland) | fr-ch |
| Georgian | ka |
| German | de |
| German (Austria) | de-at |
| German (Switzerland) | de-ch |
| Greek | el |
| Hebrew | he |
| Hindi | hi |
| Hungarian | hu |
| Indonesian | id |
| Icelandic | is |
| Irish Gaelic | ga |
| Italian | it |
| Japanese | ja |
| Kazakh | kk |
| Khmer | km |
| Korean | ko |
| Latvian | lv |
| Lithuanian | lt |
| Macedonian | mk |
| Malaysian | ms |
| Mongolian | mn |
| Norwegian | nb |
| Persian | fa |
| Polish | pl |
| Portuguese | pt |
| Portuguese (Brazil) | pt-br |
| Punjabi | pa-in |
| Romanian | ro |
| Russian | ru |
| Serbian | sr |
| Serbian (Cyrillic) | sr-cyrl |
| Sinhala | si |
| Slovak | sk |
| Slovenian | sl |
| Spanish | es |
| Spanish (Dominican Republic) | es-do |
| Spanish (United States) | es-us |
| Swedish | sv |
| Thai | th |
| Turkish | tr |
| Ukrainian | uk |
| Vietnamese | vi |
| Welsh | cy |
NOTE
This an evolution of my original Slovenian DateTime
techouse/intl-date-time 适用场景与选型建议
techouse/intl-date-time 是一款 基于 Vue 开发的 Composer 扩展包,目前已累计 209.56k 次下载、GitHub Stars 达 60, 最近一次更新时间为 2026 年 01 月 04 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「date」 「nova」 「laravel」 「datepicker」 「field」 「picker」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 techouse/intl-date-time 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 techouse/intl-date-time 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 techouse/intl-date-time 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
A Laravel Nova card that shows you your system information.
A Laravel Nova card.
Tools to convert between .NET and PHP date formats
A Laravel Nova package for publishable fields
A Laravel Nova package for translatable fields
A powerful event calendar Tool for Laravel's Nova 5.
统计信息
- 总下载量: 209.56k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 60
- 点击次数: 34
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2026-01-04
