CodeIgniter Date Helper vs PHP DateTime: Automatic DST Adjustment
0 reputation · 13 Jun 2022, 17:31 UTC
Goal
Present timestamps from the database in a user’s local time zone, honoring daylight‑saving transitions without manual manipulation.
Current Constraints
The CI Date helper delegates to PHP’s native date() and DateTime, which rely on the PHP default timezone unless the framework’s timezone config is set. The helper’s now() returns a timestamp in that configured zone, but converting to another zone requires a manual convert() call. There is no built‑in automatic DST adjustment during conversion, and changing the timezone setting after initialization does not affect existing helper instances.
Uncertainty
It is unclear whether CodeIgniter can automatically apply DST rules when converting timestamps, whether runtime timezone changes can be respected, and how to best store UTC values and display them in local time.
Questions
- Does the CI Date helper automatically apply daylight‑saving time adjustments when converting between zones?
- Can the framework’s
timezoneconfiguration be changed at runtime to affect subsequent conversions, or is a full restart required? - What is the recommended pattern for storing UTC timestamps and rendering them in a user’s local time zone with correct DST handling?