Closed rumes closed 5 years ago
Confirmed. For me it always shows 12:00AM ( for example, my time is 14:00). Only happens with PM times. Widget setup:
<?php
echo TimePicker::widget([
'name' => "DoctorSchedulePreferences[$scheduleId][end_time]",
'value' => (isset($schedule[$key]) ?
$schedule[$key]->end_time : ''),
'pluginOptions' => [
'defaultTime' => false,
'showMeridian' => true,
],
'options' => ['class' => "txtSchedule_end_time_$key"],
]);
?>
Screenshot:
Yes, I am facing same issue when I am going to update time it passes 12:00 AM. Have you found any solution?
Hello,
I got the solution for it. It insert the same value because you have not passes the time format properly.
Try this below code in your create or update function of controller:
$model->eventStartDate = date('Y-m-d',strtotime($_REQUEST['eventStartDate']));
$model->eventStartTime = date('H:i:s',strtotime($_REQUEST['eventStartTime']));
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
Hi, we were working with Postgres DB, and had a simiar issue, when we were creating the event, and the hour was set with PM, the time was successfully saved to the DB, but, when we updated the event, the time was wrong in the TimePicker input, so, to solve this, it's needed to do something similar like @bhattaxay said on https://github.com/kartik-v/yii2-widget-timepicker/issues/5#issuecomment-271077665 We solved the problem formatting the time this way:
$model->start_time = date('g:i a', strtotime($model->start_time));
The input is configured like this:
<?= $form->field($model, 'start_time')->widget(TimePicker::classname(), []) ?>
I have used kartik timepicker widget in my project as below.
but if pass time like 14:15 to the widget it shows time as 12:15 AM