Skip to content

Date fields shift by timezone offset on every resource save when PHP date.timezone is not UTC #2431

Description

@andonebz

Evolution CMS 3.5.7 and 3.3 (reproduced on both) / PHP 8.3 / date.timezone = Asia/Tokyo (default on most Japanese shared hosting: Xserver, Heteml, etc.)

Steps to reproduce:

Set date.timezone = "Asia/Tokyo" in php.ini
Edit any resource, set pub_date to 2026/09/01 10:00:00, save
Reopen the resource: field shows 2026/09/01 01:00:00 (−9h)
Save again without changes: value shifts another −9h (compounds on every save). unpub_date behaves identically; publishedon inherits the drift via its copy from pub_date. createdon/editedon are unaffected (no form round-trip).

Cause: Asymmetric timezone handling between the two converters in core/src/Core.php:

toTimeStamp() uses mktime() — interpreted in the runtime timezone (line ~4797)
toDateFormat() uses Carbon::createFromTimestamp($timestamp, 'UTC') — fixed to UTC (line ~4740)

Each open→save round-trip therefore subtracts the TZ offset. Not reproducible when date.timezone=UTC because both paths coincide.

Suggested fix: use gmmktime() in toTimeStamp() (consistent with the UTC-fixed display path), or pass date_default_timezone_get() to Carbon in toDateFormat().

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