0
When defining a variable of type Carbon
i cannot copy the object (create new instance with the same properties), just point to the same instance, forcing me to create new objects manually.
Example:
$data_inicio = Carbon::now()
->hour(0)
->minute(0)
->second(0);
\var_dump($data_inicio); // retorna data 2019-07-19
$data_limite = $data_inicio;
$data_limite->addWeeks(8);
\var_dump($data_inicio); // retorna data 2019-09-13
\var_dump($data_limite); // retorna data 2019-09-13
There is a way to copy the instance instead of pointing to the same instance of the object, so that by changing the variable $data_limite
i don’t change $data_inicio
?
Just as
$data_limite = clone $data_inicio
?– Woss