I'm trying to do a math problem using datetime in php. The problem that the string that I'm creating is dynamic. If I add as a static string it runs fine, but If I make the string dynamic it fails. Here's a code example.
$now = new DateTime();
$datetime_interval = 'P' . $filledOrder->hours . 'H'; // hours comes from an object
$now->add(new DateInterval($datetime_interval));
If I add static string to DateInterval is working fineenter code here
$now->add(new DateInterval('P10H'));
Any help would be greatly appreciated.