<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
codingwithrk / nativephp-datetime-picker example snippets
use Livewire\Component;
use Native\Mobile\Attributes\OnNative;
use Illuminate\Support\Carbon;
use Codingwithrk\NativephpDatetimePicker\Facades\DateTimePicker;
use Codingwithrk\NativephpDatetimePicker\Events\DateTimePickerConfirmed;
use Codingwithrk\NativephpDatetimePicker\Events\DateTimePickerCancelled;
class BookingForm extends Component
{
public ?string $startsAt = null;
public function pickStart(): void
{
DateTimePicker::make()
->dateTime()
->min(now())
->max(now()->addMonths(6))
->current(now())
->title('When does it start?')
->use12h()
->show();
}
#[OnNative(DateTimePickerConfirmed::class)]
public function onPicked($value, $mode, $timestamp = 0, $id = null): void
{
$this->startsAt = Carbon::parse($value)->toDateTimeString();
}
#[OnNative(DateTimePickerCancelled::class)]
public function onCancelled($id = null): void
{
//
}
}
use Codingwithrk\NativephpDatetimePicker\Facades\DateTimePicker;
DateTimePicker::date(); // date only
DateTimePicker::time(); // time, 24-hour
DateTimePicker::time12h(); // time, AM/PM
DateTimePicker::dateTime(now()); // date + time
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.