If you get this error after a fresh install of CodeIgniter 4 using php 8.4;
“Fatal error: Declaration of CodeIgniter\I18n\TimeTrait::createFromTimestamp(int $timestamp, $timezone = null, ?string $locale = null) must be compatible with DateTimeImmutable::createFromTimestamp(int|float $timestamp): CodeIgniter\Autoloader\Autoloader in /var/www/vhosts/hosting116540.a2f7e.netcup.net/v2.4u.tools/httpdocs/system/I18n/TimeTrait.php on line 268”
Looking at the error I could see a difference between the declaration and the compatibility requirement.
Declaration of CodeIgniter\I18n\TimeTrait::createFromTimestamp(int $timestamp, $timezone = null, ?string $locale = null) must be compatible with DateTimeImmutable::createFromTimestamp(int|float $timestamp):
So I went to
vendor/codeigniter4/framework/system/I18n/TimeTrait.php
And changed the declaration on line 268 from
public static function createFromTimestamp(int $timestamp, $timezone = null, ?string $locale = null)
to
public static function createFromTimestamp(int|float $timestamp, $timezone = null, ?string $locale = null)
I am not getting the error any more. This may not be a complete fix? But at least the home page of a fresh install loads now.
Leave a Reply