PHP code example of sinensia / localizeddatetime

1. Go to this page and download the library: Download sinensia/localizeddatetime library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

sinensia / localizeddatetime example snippets


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('