thinkphp5出现A non well formed numeric value encountered的解决办法修改formatDateTime方法如下

默认值:
if (is_null($this->autoWriteTimestamp)) {
// 自动写入时间戳默认false 包含datetime、date、timestamp
$this->autoWriteTimestamp = $this->getQuery()->getConfig('auto_timestamp');//getConfig:获取database.php的配置参数或者convention.php下的database项
} if (is_null($this->dateFormat)) {
// 设置时间戳格式默认Y-m-d H:i:s
$this->dateFormat = $this->getQuery()->getConfig('datetime_format');
} if (is_null($this->resultSetType)) { //数据集返回类型默认array 可选collection(返回collection对象)
$this->resultSetType = $this->getQuery()->getConfig('resultset_type');
} tp获取器部分逻辑:
存在$this->createTime或者$this->updateTime的情况下
如果$this->autoWriteTimestamp的值是datetime、date、timestamp其中一种则
执行 $value = $this->formatDateTime(strtotime($value), $this->dateFormat);
否则(值为其他情况如true):
$value = $this->formatDateTime($value, $this->dateFormat); 所以要不就关闭自动更新时间 否则formatDateTime方法第一个参数可能会出现两种情况中的一种(时间戳与非时间戳)
/**
* 时间日期字段格式化处理
* @access public
* @param mixed $time 时间日期表达式
* @param mixed $format 日期格式
* @param bool $timestamp 是否进行时间戳转换
* @return mixed
*/
protected function formatDateTime($time, $format, $timestamp = false)
{
if (false !== strpos($format, '\\')) {
$time = new $format($time);
} elseif (!$timestamp && false !== $format) {# !timestamp默认false走这里 设置为date timestap datetime则不走这里
#修改开始位置
if (!preg_match("/^[0-9]{10}|[0-9]{13}$/",$time)) {
$time=strtotime($time);
}#修改结束位置
$time = date($format, $time);
}
return $time;#直接返回
}

或者在模型文件:修改

    protected $autoWriteTimestamp=false;         // 是否需要自动写入时

又或者修改datebase.php

'datetime_format' = false
datetime、date、timestamp

tp5 报 A non well formed numeric value encountered 的错解决办法的更多相关文章

  1. 安装应用程序 报“ 997 重叠 I/O 操作在进行中”错解决办法

    解决办法: 原因: Per Microsoft's blog, patch KB2918614 appears to have caused installation issues 按照微软的博客,补 ...

  2. 关于TP5模板输出时间戳问题--A non well formed numeric value encountered

    某日.因为一个项目.控制器我是这么写的 1 /** 2 * get admin/Picture/index 3 * 显示所有图册信息 4 * @return view 5 */ 6 public fu ...

  3. 关于PHP Notice: A non well formed numeric value encountered, 你知道多少

    ---------------------------------------------------------------------------------------------- A non ...

  4. A non well formed numeric value encountered

    在从数据库获取时间戳数据的时候返回的结果是varchar类型 然后在用date("Y-m-d H:i:s", 时间戳)的时候会报错A non well formed numeric ...

  5. sphinx :undefined reference to `libiconv' 报错解决办法

    sphinx :undefined reference to `libiconv' 报错解决办法   2013-11-30 21:45:39 安装sphinx时不停报错...郁闷在make时报错,错误 ...

  6. MySQL安装过程net start mysql 启动失败 报“错误2,系统找不到文件”的解决办法

    MySQL安装过程net start mysql 启动失败 报“错误2,系统找不到文件”的解决办法 错误2,系统找不到文件. 开始...运行... regedit  注册表项: HKEY_LOCAL_ ...

  7. spring boot jpa 使用update 报错解决办法

    在spring boot jpa 中自定义sql,执行update操作报错解决办法: 在@Query(...)上添加 @Modifying@Transactional注解

  8. Aasible中cryptography兼容性报错解决办法

    Aasible中cryptography兼容性报错解决办法 1 Ansible中使用ansible --version查看版本,报错信息如下: ERROR! Unexpected Exception, ...

  9. sysctl -P 报错解决办法

    sysctl -P 报错解决办法问题症状修改 linux 内核文件 #vi /etc/sysctl.conf后执行sysctl  -P 报错error: "net.bridge.bridge ...

随机推荐

  1. php array_unshift,array_push追加数组元素

    追加元素在数组前面:<?php $a=array("a"=>"Cat","b"=>"Dog"); ar ...

  2. java中 ++a 与 a++ 的区别

    public static void main(String[] args) { int a = 5; a ++; System.out.println(a); int b = 5; ++ b; Sy ...

  3. appium + python 自动化调试手机时 UiAutomator exited unexpectedly with code 0, signal null

    放上appium报错图,appium在手机里安装了appium setting 和unlock 软件,输入法也被变成了appium input ,但是就是点不到目标软件,手机也可以被cmd  adb ...

  4. LGP5495 Dirichlet 前缀和

    题目 不是很明白为什么要叫做模板 考虑到\(a_i\)能对\(b_j\)产生贡献,当且仅当\(a_i=\prod p_k^{a_k},b_j=\prod p_k^{b_k},\forall k \ a ...

  5. iOS开发系列-线程状态

    概述 线程从创建到销毁中间存在很多种状态. 线程的状态 通过NSThread创建一条线程,开发者需要负责线程的创建和执行,线程的销毁由系统决定.创建一个继承NSThread的FMThread类,重写d ...

  6. asp.net去除HTML标签

    public string NoHTML(string Htmlstring) //替换HTML标记 { //删除脚本 Htmlstring = Regex.Replace(Htmlstring, @ ...

  7. opencv-识别手写数字

    首先拆分图片得到数据 #include "stdafx.h" #include <iostream> #include "opencv2/opencv.hpp ...

  8. Android开发 WebView的详解

    前言 WebView 是Android显示html内容的主要方式,当然TextView也可以加载html内容.但是WebView除了功能更加强大,最重要的是还能调用Html里的JavaScript语言 ...

  9. centos6 php5.4 升級到php 5.6

    因Centos6中的PHP版本有点底,需要升级PHP版本 [vagrant@localhost ~]$ php -v PHP 5.4.45 (cli) (built: Sep 30 2015 15:0 ...

  10. 阿里云MaxCompute 2019-8月刊

    您好,MaxCompute 2019.8月刊为您带来8月产品.技术最新动态,欢迎阅读. 导读 [重要发布]8月产品重要发布 [文档更新]8月重要文档更新推荐 [干货精选]8月精选技术文章推荐 [精彩活 ...