Level 104
The problem is mapInto passes the array (collection) key into the constructor as the second argument (which Carbon sees as the TZ offset)!
public function mapInto($class)
{
return $this->map(function ($value, $key) use ($class) {
return new $class($value, $key);
});
}
Instead:
collect($dates)->map(fn ($date) => \Carbon\Carbon::parse($date));
2 likes