日期时间格式,更改格式。

发布于 2024-10-09 22:11:20 字数 245 浏览 0 评论 0原文

我在页面数据库中有一个时间戳,因此采用这种格式 $d="2011-01-03 12:53:22"

当我尝试通过 date(" 发送该时间戳时c",$d) 我只得到 1970-01-01T10:33:31+10:00

我在 php 手册中读到 date("c",THIS) 必须是一个 INT 那么我用什么来从“2011-01-03 12:53:22”获取 int ?

I have a TIMESTAMP in the database for pages, so in this format $d="2011-01-03 12:53:22"

And when i try to send that through date("c",$d) I only get 1970-01-01T10:33:31+10:00

I have read in the php manual that date("c",THIS) must be an INT so what do i use to get the int from "2011-01-03 12:53:22"??

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

此刻的回忆 2024-10-16 22:11:20

发送日期函数时忘记将日期字符串转换为时间戳

date('c', strtotime($d));

you forget to convert the date string to timestamp when sending for date function

date('c', strtotime($d));
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文