Why does PHP believe my date is a string? -


my code giving me error "fatal error: call member function sub() on string" can see $date variable string based on echo, still believes string.

my code:

echo $stringdate;     //prints "2014-03-27" $date = date('yyyy-mm-dd', strtotime( $stringdate ); echo $date;     //prints "14141414-0303-2727" $date->sub(new date_interval_create_from_date_string('70 days') );     //produces "fatal error: call member function sub() on string" $milestones["method development checklist"]['date'] = $date; 

instead of

date('yyyy-mm-dd', strtotime( $stringdate )); 

use

date_create_from_format("y-m-d", $stringdate); 

which alias for

datetime::createfromformat("y-m-d", $stringdate); 

have nice day o/


Comments