PHP sandbox
PHP strtotime() Online
Turn an English date phrase into a Unix timestamp with an explicit time zone and reference time. Runs on real PHP 8.2 on our server when you press Run.
About strtotime()
strtotime() parses an English date or time phrase into a Unix timestamp: absolute dates such as 2024-03-15 12:00:00, and relative ones such as +1 week, next monday or last day of next month.
Relative phrases are counted from the base timestamp, and times without an explicit zone are read in the default time zone. Both change the answer, so this sandbox asks for both instead of using the server clock.
An unparseable phrase returns false. When the result is an integer the sandbox also prints the date it stands for.
Worked example
date_default_timezone_set('UTC');
var_dump(strtotime('+1 week', 1700000000));
// int(1700604800)Frequently asked questions
Why does strtotime() give a different result on my server?
Its default time zone or current time differs. Call date_default_timezone_set() and pass a base timestamp to get repeatable results.
How do I check that strtotime() failed?
Compare with === false. Timestamp 0 (1 January 1970) is a valid result.
Is my input sent to a server?
Yes. These pages run real PHP 8.2 on the w3docs server, so the text you enter is sent there to run, in a sandbox with no network access. Do not paste passwords, keys or personal data.
How much input can I send?
Up to 6,000 bytes across all text fields, which is about 6,000 characters of plain text (accented letters and emoji take 2 to 4 bytes). Larger input is refused before anything is sent.