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()转换)  

    路是自己走出来的,而不是选出来的。
  • 相关阅读:
    java的概述 常量 变量
    css 基础2
    css 盒子模型1
    css 基础1
    HTML 基础 3
    HTML基础2
    servletContext百科
    hibernate 一对多双向关联 详解
    hibernate generator class="" id详解
    Hibernate缓存原理与策略
  • 原文地址:https://www.cnblogs.com/mo3408/p/14360905.html
Copyright © 2011-2022 走看看