如何在 yii2 中使用 AM/PM 节省时间

How to save time along with AM/PM in yii2

我的 table 中有一个名为 departure_time 的字段。 当我试图保存时间时,它显示 "Invalid datetime format: 1292 Incorrect time value: '11:15 AM' for column 'departure_time' at row 1" 错误。
我的 table 中 departure_time 的数据类型是 TIME。我正在使用 kartiks 时间选择器。帮我找到这个解决方案。

基本上时间 data_type 格式只存储时间值 databse.Also 它只需要 24 小时格式而不是上午或下午格式。如果你想要存储价值,他们有两个解决方案。

In data base , The data_type of field should be varchar. it will be store your value as you want.

You have to change your deprature_time in 24 hour format and store in database when you want to fetch it then use php date("h:i a") format on field. It will return your time value AM/PM format