gpt4 book ai didi

javascript - jquery datetimepicker 插件 am/pm - 数据库中的所有 pm 字符串

转载 作者:行者123 更新时间:2023-11-29 00:21:50 26 4
gpt4 key购买 nike

我正在使用 codeigniter 和 jquery datetimepicker 插件。在我的 View 页面上,我有类似

的日期时间选择器格式
$(".traveler").datetimepicker({
dateFormat: 'yy-mm-dd',
timeFormat: 'hh:mm tt',
//other stuff
});

在我的 codeigniter Controller 操作方法中有

 'arrivaldate' => date('Y-m-d h:i:s a', strtotime($this->input->post('arrivaldate'))), 
'departuredate' => date('Y-m-d h:i:s a', strtotime($this->input->post('departuredate'))),

保存到数据库后,它看起来像这样 2013-12-04 08:00:00

当我从数据库读取到 present 时,我在 php 中执行此操作

date("Y-m-d h:i a",strtotime($myrow['arrivaldate']))

当我再次在我的 View 页面上显示它时,它看起来像 2013-12-04 08:00 am 而它应该说 2013-12-04 08:00 pm

出于某种原因,我无法弄清楚为什么?它必须符合我的格式,而且我整天都在处理它。有什么想法吗?

最佳答案

您的问题是时间。数据库时间 DATETIME 以军用时间存储。

改成

date("Y-m-d H:i:s", strtotime($somevariablehere));

现在,当您将其保存在数据库中时,它将是正确的。

关于javascript - jquery datetimepicker 插件 am/pm - 数据库中的所有 pm 字符串,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20768361/

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