Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

mstdmstd's avatar

Why air-datepicker does not support formatted datetime from database?

In laravel 8.83 / air-datepicker 2.2.3 / jquery 3.6.0 app I need to use datepicker with time selection and in resources/js/app.js I have :

require('air-datepicker/src/js/air-datepicker');
$('.datetime_picker').datepicker({
    toggleSelected: false,
    timepicker: true,
    timeFormat: 'h:m',
    buttons: ['today', 'clear'],
})

and in blade php file :

<span class="d-block mb-1">{{ $news->published_at }}</span>
        <input
            class="form-control datetime_picker"
            name="published_at"
            id="datetime_picker_published_at"
            value="{{ old('published_at', $news->published_at?->format('d.m.Y H:i')) }}"
            data-language="{{ app()->getLocale() }}"
            data-date-format="dd.mm.yyyy H:i"
            data-clear-button="true"
            data-auto-close="true"
            autocomplete="off"
        />

As result when form is opened with existing date I see valid datetime in input, but a) opening datetime pickup it has not existing date , but current date and time. b) I can select date and hour by dragging hour scroller, but minutes are not selected when I drag minutes scroller c) Can I add some “Select” button when I need to select datetime into input and close pickup dialog?

0 likes
2 replies
Snapey's avatar

try setting the value to a standard format

value="{{ old('published_at', $news->published_at?->format('Y-m-d H:i')) }}"

mstdmstd's avatar

@Snapey No it did not help. Just other format in date when for is opened

Please or to participate in this conversation.