sinensia / localizeddatetime
A custom localized DateTime field for Laravel Nova 4 (Laravel 10+ compatible).
Installs: 15
Dependents: 0
Suggesters: 0
Security: 0
Stars: 1
Watchers: 2
Forks: 0
Open Issues: 0
Language:Vue
Type:nova-field
Requires
- php: ^8.1
- laravel/nova: ^4.0
README
š
A custom DateTime field for Laravel Nova 4 with localization support.
This package extends VueDatePicker to provide a flexible and user-friendly date selection experience.
TODO:Test in Nova 5
š Installation
Step 1: Add the package to your Laravel Nova project:
composer require sinensia/localizeddatetime
Step 2: Install Dependencies
Before installing the package, ensure your system has the required PHP extensions bcmath and zip.
1ļøā£ Install Required PHP Extensions
For Ubuntu/Debian users, run:
sudo apt update sudo apt install php-bcmath php-zip -y
2ļøā£ Verify That Extensions Are Enabled
Check if the extensions are active (for example, in Apache):
php -m | grep -E "bcmath|zip"
If any extension is missing, you may need to restart PHP:
sudo systemctl restart apache2 # For Apache users sudo systemctl restart php-fpm # For Nginx with PHP-FPM
š ļø Usage
In your Nova Resource:
use Sinensia\Localizeddatetime\LocalizeddateTime; public function fields(NovaRequest $request) { return [ Localizeddatetime::make('Fecha Inicio') ->withMeta([ 'locale' => auth()->user()->locale, // You can use the authenticated user locale 'firstDayOfWeek' => 1, // Monday 'dateFormat' => 'dd/MM/yyyy HH:mm', 'enableTimePicker' => true, 'range' => true, // Allow a date range setup 'showShortValue' => false, // Index field can show short format i.e. 11/02 or full 11/02/2025 14:00 'presetRanges' => [ ['label' => 'Hoy', 'range' => [now(), now()]], ['label' => 'Este mes', 'range' => [now()->startOfMonth(), now()->endOfMonth()]], ['label' => 'El mes pasado', 'range' => [now()->subMonth()->startOfMonth(), now()->subMonth()->endOfMonth()]], ['label' => 'Este trimestre', 'range' => [now()->startOfQuarter(), now()->endOfQuarter()]], ['label' => 'Este aƱo', 'range' => [now()->startOfYear(), now()->endOfYear()], 'slot' => 'yearly'], ], ]) ->rules('required', 'date'), ]; }
š§ Available Meta Options
Option | Description |
---|---|
locale |
User's preferred locale (ca , es , en ) |
firstDayOfWeek |
First day of the week (1 = Monday, 0 = Sunday) |
dateFormat |
Example: dd/MM/yyyy HH:mm |
enableTimePicker |
true : Enables time selection, false : Date only |
range |
true : Allows date range selection, false : Single date |
showShortValue |
true : Shows only day/month, false : Shows full date |
presetRanges |
Predefined date ranges for quick selection |
šļø Compatibility
- ā Laravel Nova 4+
- ā Vue 3
- ā VueDatePicker 3.x
- ā Date-FNS for localization
š Credits
Developed by Sinensia
GitHub Repository
š License
This package is open-source and released under the MIT License.