I am trying to add 30 days to the current day using the php modify() function and I also am putting timezone in the datetime here is my code:
$country_code = 'PH';
$timezone = \DateTimeZone::listIdentifiers(\DateTimeZone::PER_COUNTRY, $country_code);
$new_date = (new \DateTime("now", new \DateTimeZone($timezone[0])))->format('Y-m-d H:i:s');
$datetime = $new_date->modify('+30 days');
$end_date = $datetime->format('Y-m-d H:i:s');
I am getting the error:
Call to a member function modify() on string
When I echo the $new_date it is in proper MySQL datetime format 'Y-m-d H:i:s'. What am I doing wrong?