strtotime返回false如何解决?
2018-07-13 16:18
阅读:3256
在做项目的时候,发现代码在线上没问题,但是在本地就出现另一种结果,经过排查发现是strtotime这个函数引起的。
于是网上查资料,原来是32位系统与64位系统或者是32位php和64位php引起的这样的问题。
那么如何解决呢。写了个函数,自定义一个新的 strtotime来完成。我把它命名为str2time
1 2 3 4 5 6 7 8 9 10 11 12 | /** * 字符串转化为时间戳 * @param $str * @return int|string */ private function str2time( $str ){ if (! $str ){ return 0; } $obj = new \DateTime( $str ); return $obj ->format( "U" ); } |
文章来自:搜素材网的好文分享模块,转载请注明文章出处。
文章标题:strtotime返回false如何解决?
文章链接:http://soscw.com/index.php/article/8367.html
文章标题:strtotime返回false如何解决?
文章链接:http://soscw.com/index.php/article/8367.html
评论
亲,登录后才可以留言!