gpt4 book ai didi

php - 如何在MySQL opencart中将12转换为24

转载 作者:行者123 更新时间:2023-11-29 21:52:43 24 4
gpt4 key购买 nike

我正在尝试从 OpenCart 中的 MySQL 获取插入时间和分钟相反,当我单击单独保存时,它会始终在上午 12:00 更新输入值

这是查询

$this->db->query("UPDATE " . DB_PREFIX . "delivery_time SET delivery_time_name = '" . $this->db->escape($data['delivery_time_name']) . "', delivery_time_from = 'TIME( STR_TO_DATE( " . $this->db->escape($data['delivery_time_from']) . ", \"%h:%i %p\" ) )', delivery_time_to = '" . $this->db->escape($data['delivery_time_to']) . "', status = '" . (int)$data['status'] . "' WHERE delivery_time_id = '" . (int)$delivery_time_id . "'");

但在 phpmyadmin 上工作相同

UPDATE `oc_delivery_time` SET `delivery_time_name`="Slot2",`delivery_time_from`=TIME( STR_TO_DATE( "9:30 AM", "%h:%i %p" ) ),`delivery_time_to`=TIME( STR_TO_DATE( "12:00 PM", "%h:%i %p" ) ),`status`="1" WHERE `delivery_time_id`="2"

最佳答案

使用 MySQL STR_TO_DATEinterval

STR_TO_DATE('1:00 PM', ' %h:%i')+ interval 12 hour

或者尝试这个查询:-

Select STR_TO_DATE('1:00 PM', ' %h:%i')+ interval 12 hour

关于php - 如何在MySQL opencart中将12转换为24,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33475823/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com