Home > front end >  Carbon addDays() not working properly in factory
Carbon addDays() not working properly in factory

Time:11-21

Anyone know why this factory is giving same time for all variables?

enter image description here

What I get is this:

enter image description here

CodePudding user response:

this is the way how carbon works ... $from->addDays(3) will make $from itself after three days ...

to avoid this, you can use make method:

$to= Carbon::make($from)->addDays(rand(1,7));

make method will make a copy of the variable, as you expect.

  • Related