zoukankan      html  css  js  c++  java
  • 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()转换)  

    路是自己走出来的,而不是选出来的。
  • 相关阅读:
    linux创建用户
    Java理解笔记------杂项
    java高效并发
    GPG备份秘钥
    (二)数据同步利器syncthing
    (一)安装samba
    (序)利旧打造私有云
    mysql的docker化安装
    (八)netty的SSL renegotiation攻击漏洞
    (七)json序列化
  • 原文地址:https://www.cnblogs.com/mo3408/p/14360905.html
Copyright © 2011-2022 走看看