警告:date()期望参数2较长,字符串在中给出 [英] Warning: date() expects parameter 2 to be long, string given in

查看:204
本文介绍了警告:date()期望参数2较长,字符串在中给出的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在数据库的car_detail.php页面上收到此错误

i keep getting this error on the car_detail.php page on my database

警告:date()期望参数2长,在第228行的/home/speedycm/public_html/speedyautos/cars_class.php中给出的字符串*

Warning: date() expects parameter 2 to be long, string given in /home/speedycm/public_html/speedyautos/cars_class.php on line 228*

cars_class.php在第228行读取此内容

cars_class.php reads this on line 228

$this->expiry_date = date("m/d/Y", $rows['expiry_date']);

我该如何解决?

推荐答案

date( )需要一个unix时间戳...我想您是将日期作为字符串传递给它.

date() expects a unix timestamp... I imagine you are passing it a date as a string.

例如2010-10-10

e.g. 2010-10-10

您应该使用:

$this->expiry_date = date("m/d/Y", strtotime($rows['expiry_date']));

或更妙的是,使用 DateTime 对象.

Or better yet, use the DateTime object.

$expiry_date = new DateTime($rows['expiry_date']);
$this->expiry_date = $expiry_date->format('m/d/Y');

这篇关于警告:date()期望参数2较长,字符串在中给出的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆