Skip to content

date: Skip timelib parsing in strtotime() for "now" - #25718

Open
adapik wants to merge 1 commit into
php:masterfrom
adapik:date-strtotime-now-shortcut
Open

adapik wants to merge 1 commit into
php:masterfrom
adapik:date-strtotime-now-shortcut

Conversation

@adapik

@adapik adapik commented Nov 24, 2026

Copy link
Copy Markdown
Contributor

While working on #25702, I noticed that strtotime() behaves the same way. For "now" the parsed result is an empty timelib_time, and timelib_fill_holes() copies everything from the base time. The final timestamp is therefore just the base timestamp ($baseTimestamp, or the current time when it is omitted). Still, strtotime("now") scans the string, allocates a timelib_time, fills holes and runs timelib_update_ts(), and then returns the value it started with.

Release build, ns per call (median of 7 runs):

Call master patched Change
strtotime("now") 187.8 36.3 −81%

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant