DateTime::createFromFormat(): Failed to parse time string in modx/date.php
0 reputation · 19 Jun 2023, 19:48 UTC
Goal
To determine how ModX should handle regional time zones when converting stored UTC timestamps to the user’s locale.
Context
The core file modx/model/modx/date.php throws a generic exception when DateTime::createFromFormat receives an invalid timezone string, resulting in the PHP warning "DateTime::createFromFormat(): Failed to parse time string". ModX stores all timestamps as UTC in the database, but the PHP DateTime objects are instantiated using the server’s default timezone unless overridden by the user’s locale settings. The time_zone system setting only sets the default PHP timezone during bootstrap and does not affect how dates are displayed for users in different regions.
Unresolved Decision
There is no automatic conversion of stored UTC timestamps to the user’s timezone when rendering dates in the front‑end or manager interface, and error messages for unsupported timezone identifiers are not localized.
Specific Questions
- Should ModX automatically convert UTC timestamps to the user’s locale when rendering dates, and if so, what mechanism should be used?
- How should unsupported timezone identifiers be handled to provide localized error messaging instead of the generic PHP warning?
- Is there a plan to expose a per‑user timezone setting in System Settings to override the default PHP timezone?