ThinkPHP5显示A non well formed numeric value encountered错误的解决办法

编程入门 行业动态 更新时间:2024-10-25 10:34:38

ThinkPHP5显示A non well formed numeric value encountered错误的<a href=https://www.elefans.com/category/jswz/34/1767401.html style=解决办法"/>

ThinkPHP5显示A non well formed numeric value encountered错误的解决办法

第一种:解决办法:关闭时间戳自动转换功能。

1.全局关闭,在config.php文件中加入以下代码:

'datetime_format' = false

2.模型关闭,在对应的模型中加入以下代码:

public function getCreateTimeAttr($time)
{return $time;//返回create_time原始数据,不进行时间戳转换。
}

 第二种:

1、模板中格式化输出时间

{$time|strtotime|date="Y年m月d日 h时:i分:s秒",###}

$time 是日期字符串,一般后台的时间是"Y-m-d h:i:s"

strtotime()把字符串转化为时间整数

date(format, timestamp) 把整数时间timestamp按照format格式转换为字符串

"###"表示前面的变量在date函数中的传入位置

2、数据库表时间字段设置 int类型,

    模板中直接输出时间{$time}

3.检测数据类型(不一样的使用intval()转换)  

更多推荐

ThinkPHP5显示A non well formed numeric value encountered错误的解决办法

本文发布于:2024-03-23 22:01:25,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1743334.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:解决办法   错误   formed   encountered   numeric

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!