Skip to content

Conversation

@dereuromark
Copy link
Member

Summary

Date does not have setTimezone() method, only DateTime does. This adds an instanceof check to prevent calling setTimezone on Date objects.

This matches the pattern already used in dateAgoInWords() method in the same class.

Fix

// Before
if ($options['timezone']) {
    $time = $time->setTimezone($options['timezone']);
}

// After
if ($time instanceof DateTime && $options['timezone']) {
    $time = $time->setTimezone($options['timezone']);
}

@dereuromark dereuromark added this to the 5.3.0 milestone Dec 13, 2025
Date does not have setTimezone() method, only DateTime does.
Add instanceof check to prevent calling setTimezone on Date objects.

This matches the pattern already used in dateAgoInWords().
@ADmad ADmad merged commit c78c927 into 5.x Dec 13, 2025
15 checks passed
@ADmad ADmad deleted the 5.x-setTimezone-fix branch December 13, 2025 19:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants