php / php/php-src

DateTime::modify('-1 second') goes 59 minutes later on DST

Đang mở
#21,616 3 bình luận 0 reaction 1 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Bug Extension: date Status: Verified
Ngôn ngữ chính
C
Star
40.4k
Fork
8.2k
Merge trung bình
2 ngày 13 giờ
Pull request đã merge (30 ngày)
96

Mô tả

Description

The following code:

<?php
echo (new DateTime('2025-03-30 00:59:59', new DateTimeZone('Europe/London')))
    ->modify('+1 second')
    ->modify('-1 second')
    ->format('Y-m-d H:i:s.u e T');

Resulted in this output:

2025-03-30 02:59:59.000000 Europe/London BST

But I expected this output instead:

2025-03-30 00:59:59.000000 Europe/London GMT

Which is also the output we get when executing (since PHP 8.1, before that add/sub interval and modify gave the same output):

echo (new DateTime('2025-03-30 00:59:59', new DateTimeZone('Europe/London')))
    ->add(new DateInterval('PT1S'))
    ->sub(new DateInterval('PT1S'))
    ->format('Y-m-d H:i:s.u e T');
PHP Version
PHP 8.5.3
Possibly related to

#15880

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.