gpt4 book ai didi

php - 如何在 Dreamweaver 中按记录源格式化日期显示

转载 作者:行者123 更新时间:2023-11-29 20:47:44 25 4
gpt4 key购买 nike

我的 MySQL 和 php 项目中有以下代码。它是显示日期的表格行。日期字段称为 [DatePosted],如下所示。当我运行代码时,日期以 2016-07-11 09:53:15 格式显示,这是我不想要的。我希望它以 11-07-2016 09:53:15 格式显示。

您能帮我实现这一目标吗?我可以在下面的代码中的哪里插入格式化脚本?

最佳答案

您可以使用datestrtotime PHP 函数从给定字符串获取格式化日期。

这是您可以做到的方法,

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

In above code strtotime function converts any English textual datetime description into a Unix timestamp and,

date function accepts two parameters, first is the date format you want to get and second parameter accepts unix timestamp.

Second parameter in date function is optional, if not given it displays the current date in given format.

演示: https://eval.in/603859

关于php - 如何在 Dreamweaver 中按记录源格式化日期显示,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38324842/

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