Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Warning: date() expects parameter 2 to be long, string given in

Tags:

php

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

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 reads this on line 228

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

how can i resolve this?

like image 415
methuselah Avatar asked Dec 05 '22 23:12

methuselah


1 Answers

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

e.g. 2010-10-10

You should use:

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

Or better yet, use the DateTime object.

$expiry_date = new DateTime($rows['expiry_date']);
$this->expiry_date = $expiry_date->format('m/d/Y');
like image 148
Jacob Avatar answered Dec 10 '22 11:12

Jacob