php - 回声新日期时间();在 wordpress 上导致严重错误
问题描述
如果我去我的 wordpress 网站
<?php $theCurrentDate = new DateTime(); ?>
<?php echo $theCurrentDate; ?>
它导致我的网站出现严重错误,为什么?
<?php
try {
$dt = new DateTime();
echo $dt;
} catch (Exception $e) {
var_dump($e->getMessage());
}
?>
我仍然在现场遇到严重错误。
这里发生了什么?当你在 php 中回显 datetime() 时怎么会破坏 wordpress?
解决方案
https://www.php.net/manual/en/datetime.format.php
显然你必须指定格式
<?php $theCurrentDate = new DateTime(); ?>
<?php echo $theCurrentDate->format('Y-m-d H:i:s'); ?>
推荐阅读
- oracle-apex - 在 Oracle Apex 经典报告中显示星级
- python - werkzeug 的 LocalProxy.__local,它在哪里初始化?
- javascript - JSON 数组项返回未定义
- spring-data-jpa - Spring JPA 在 @Embeddable 类中使用主键
- swift - Firebase swift跨应用用户共享不起作用
- javascript - 如何从容器对象中过滤非空对象?
- c - 如何在我的 C 代码中跟踪核心转储?
- c# - 如何解决这个二阶方程计算?
- django - 如何使用 DRF JWT resfresh
- apache-camel - 无法使用骆驼占位符在 application.properties 中设置 azure blobname