Skip to content

When I set the time zone and calculated the week number, the result was incorrect. #17723

@paulgao

Description

@paulgao

Description

The following code:

date_default_timezone_set('UTC');

echo date('Y-m-d H:i:s', 1640972671) . "\r\n";
echo date('Y-W', 1640972671) . "\r\n";

date_default_timezone_set('Asia/Shanghai');

echo date('Y-m-d H:i:s', 1640972671) . "\r\n";
echo date('Y-W', 1640972671) . "\r\n";

Resulted in this output:

2021-12-31 17:44:31
2021-52
2022-01-01 01:44:31
2022-52

But I expected this output instead:
2021-12-31 17:44:31
2021-52
2022-01-01 01:44:31
2021-52

PHP Version

7.4.33 and 8.4.3

Operating System

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions