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

davy_yg's avatar
Level 27

Timepicker

Loading date:

   <input  name="time" class="timepicker" type="text" placeholder="" value="{{ ($data) ? $data->time : old('time') }}">

...

<script>
$('.timepicker').timepicker({
    timeFormat: 'h:mm p',
    interval: 30,
minTime: '0',
    maxTime: '11:00pm',
    defaultTime: '11',
    startTime: '0:00',
    dynamic: false,
    dropdown: true,
    scrollbar: true
});
</script>

I wonder why the timepicker does not shows the correct value?

<?php echo $data->time; ?>

01:00:00

The value is 11:00 AM. And the $data->time value is 1:00:00 . I wonder why instead of showing 1:00 PM it shows 11:00 AM which is the first value of time picker?

0 likes
2 replies
andreich1980's avatar

I guess the problem is with timezones. Did you set it correct in your config/app.php? Does the Timepicker have the timezone property?

vajid's avatar
$('.timepicker').timepicker({
    timeFormat: 'h:mm p',
    interval: 30,
minTime: '0',
    maxTime: '11:00pm',
    defaultTime: '11', //<- tried removing this? or setting it as "{{$data->time}}"
    startTime: '0:00',
    dynamic: false,
    dropdown: true,
    scrollbar: true
});

Please or to participate in this conversation.