php - Cannot convert DateTime object to string -
i trying generate date (after 7 months now) here code
$cdate = new datetime("+7 months"); $cdate->modify("-" . ($cdate->format('j')-1) . " days"); $expiry_date= $cdate->format('y-m-d'); $expiry_date = strtotime($expiry_date);
which gives error:
php catchable fatal error: object of class datetime not converted string
it working before ... problem??
datetime class has no magic method __tostring(), cannot use object string.
you should use gettimestamp()
$cdate = new datetime("+7 months"); $expiry_date = $cdate->gettimestamp();
Comments
Post a Comment