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

Popular posts from this blog

c# - Send Image in Json : 400 Bad request -

jquery - Fancybox - apply a function to several elements -

An easy way to program an Android keyboard layout app -