Skip to content

Commit

Permalink
Don't override the timezone when called with a DateTime object
Browse files Browse the repository at this point in the history
  • Loading branch information
alphp committed May 15, 2024
1 parent ced926c commit bb8a957
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ Thumbs.db
#######################
/.vscode
/composer.lock
.phpunit.result.cache
# vim
*~
*.swp
Expand Down
4 changes: 2 additions & 2 deletions src/php-8.1-strftime.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@ function strftime (string $format, $timestamp = null, ?string $locale = null) :
} catch (Exception $e) {
throw new InvalidArgumentException('$timestamp argument is neither a valid UNIX timestamp, a valid date-time string or a DateTime object.', 0, $e);
}
}

$timestamp->setTimezone(new DateTimeZone(date_default_timezone_get()));
$timestamp->setTimezone(new DateTimeZone(date_default_timezone_get()));
}

$locale = Locale::canonicalize($locale ?? (Locale::getDefault() ?? setlocale(LC_TIME, '0')));

Expand Down

0 comments on commit bb8a957

Please sign in to comment.