diff --git a/src/php-8.1-strftime.php b/src/php-8.1-strftime.php index d34f065..40eef9d 100644 --- a/src/php-8.1-strftime.php +++ b/src/php-8.1-strftime.php @@ -41,7 +41,7 @@ function strftime (string $format, $timestamp = null, ?string $locale = null) : $timestamp->setTimezone(new DateTimeZone(date_default_timezone_get())); - $locale = Locale::canonicalize($locale ?? setlocale(LC_TIME, '0')); + $locale = Locale::canonicalize($locale ?? (Locale::getDefault() ?? setlocale(LC_TIME, '0'))); $intl_formats = [ '%a' => 'ccc', // An abbreviated textual representation of the day Sun through Sat