代码块应该能够自己说话。时区Europe/Berlin被检测为+02:00但行为类似+01:00。当我专门用作+02:00时区时,它按预期工作。谁能向我解释这里发生了什么?
>>> $timezone = new DateTimeZone('Europe/Berlin')
=> DateTimeZone {#2356
timezone: Europe/Berlin (+02:00),
}
>>> $timestamp = DateTime::createFromFormat('Y-m-d\TH:i:s.uO', '2020-02-29T07:30:00.000+0100')
=> DateTime @1582957800 {#2349
date: 2020-02-29 07:30:00.0 +01:00,
}
>>> $timestamp->setTimezone($timezone)
=> DateTime @1582957800 {#2349
date: 2020-02-29 07:30:00.0 Europe/Berlin (+01:00),
}
>>> $timezone = new DateTimeZone('+02:00')
=> DateTimeZone {#2371
timezone: +02:00,
}
>>> $timestamp = DateTime::createFromFormat('Y-m-d\TH:i:s.uO', '2020-02-29T07:30:00.000+0100')
=> DateTime @1582957800 {#2364
date: 2020-02-29 07:30:00.0 +01:00,
}
>>> $timestamp->setTimezone($timezone)
=> DateTime @1582957800 {#2364
date: 2020-02-29 08:30:00.0 +02:00,
}
烙印99