Consider the following block of code, I've passed a string to the DateTime
constructor. Now in line 3 I change the contents of the variable i've used, I get an error from line 2?
Why would I get an error from the constructor in line 2 from what I've done in line 3?
I've also tried clone
on the $user
object then having one object for the datetime and another for altering its contents. It still doesn't work, gives me the exact same error.
$userDatetime = "".$user->user_api_rolling_datetime;
$rollingHourEndsAt = new \DateTime($userDatetime);
$user->user_api_rolling_datetime = new Expression('NOW()');
The Error:
DateTime::__construct(): Failed to parse time string (NOW()) at position 3 ((): Unexpected character