Modifying FrozenTime inside foreach clause

Hello, I encountered something that I don’t fully realize why does it work like this.

Let’s say I execute the whole code at 2022-07-26 16:00:00 UTC and my app is configured as UTC.

After the first saveMany(), everything works as intended, saving both dates as 2022-07-26 16:00:00

After the second saveMany(), the updated field is saved on the database as 2022-07-26 13:00:00.

This does not happen if I use a for() instead of a foreach(). Both fields are datetime on MySQL and I’m using CakePHP 4.4.2

Why does this happen? Thanks in advance.

    $from = new FrozenTime('now', 'UTC');
    $to = new FrozenTime('now', 'UTC');

    $entities[] = $this->fetchTable('Entity')->newEntity([
        'from' => $from,
        'to' => $to,
    ]);

    $entities = $this->fetchTable('Entity')->saveMany($entities);

    foreach ($entities as &$entity) {
        $entity->to = new FrozenTime('now', 'America/Argentina/Buenos_Aires');
    }

    $entities = $this->fetchTable('Entity')->saveMany($entities);

    debug($entities);
    die;