Skip to content

Stdlib: DateTime @unix timestamp parse (#10858)#18566

Merged
PurHur merged 1 commit into
masterfrom
fix/10858-datetime-at-timestamp-v2
Jul 13, 2026
Merged

Stdlib: DateTime @unix timestamp parse (#10858)#18566
PurHur merged 1 commit into
masterfrom
fix/10858-datetime-at-timestamp-v2

Conversation

@PurHur

@PurHur PurHur commented Jul 13, 2026

Copy link
Copy Markdown
Owner

Problem

Zend accepts unix-timestamp strings with an @ prefix for date_create('@0'), new DateTime('@0'), and DateTimeImmutable('@0'). VM failed to parse: date_create() warned and returned false; constructors threw misleading timezone errors.

php-src reference: ext/date/php_date.cphp_parse_date() @ unix timestamp branch

Fix

PHP-in-PHP in lib/VM/DateTimeSupport.php:

  • Added tryParseAtUnixTimestampString() for @<int|float> suffix
  • Wired into initDateTime() and tryNewDateTimeLikeVariable() (date_create() path)
  • @ form sets timestamp directly with +00:00 timezone (Zend TIMELIB_ZONETYPE_OFFSET), ignoring default/ctor timezone

No new C runtime logic.

Verification

./script/docker-exec.sh -- bash -lc 'source script/php-env.sh
php test/repro/maintainer_gap_datetime_at_timestamp.php
php bin/vm.php test/repro/maintainer_gap_datetime_at_timestamp.php'
# OK / OK

./script/docker-exec.sh -- bash -lc 'source script/php-env.sh && vendor/bin/phpunit --filter datetime_at_timestamp test/compliance/VMTest.php'
# OK (1 test)

php script/bootstrap-inventory.php --check
# OK 4769/4769

Closes #10858

Made with Cursor

Teach DateTimeSupport to detect leading @<digits> time strings per
php-src ext/date/php_date.c — set epoch from numeric suffix and force
+00:00 timezone regardless of default tz or ctor timezone arg.

Co-authored-by: Cursor <cursoragent@cursor.com>
@PurHur PurHur merged commit d6faee4 into master Jul 13, 2026
1 check passed
@PurHur PurHur deleted the fix/10858-datetime-at-timestamp-v2 branch July 13, 2026 09:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Stdlib: DateTime('@timestamp') / date_create('@0') — unix @-prefix parse missing (ext/date/php_date.c)

1 participant