Skip to content

strtotime ignores timezone for "now" #20153

@kkmuffme

Description

@kkmuffme

Description

https://3v4l.org/doBhT
The following code:

<?php echo date_default_timezone_get() . PHP_EOL; echo time() . PHP_EOL; echo strtotime('now') . PHP_EOL; date_default_timezone_set('America/Los_Angeles'); echo date_default_timezone_get() . PHP_EOL; echo time() . PHP_EOL; echo strtotime('now') . PHP_EOL;

Resulted in this output:

Europe/Amsterdam 1760299473 1760299473 America/Los_Angeles 1760299473 1760299473 

But I expected this output instead:
strtotime timestamps should not be in UTC time zone because

https://www.php.net/manual/en/function.strtotime.php

Each parameter of this function uses the default time zone

When using e.g. '2025-10-12' instead of 'now' it suddenly does not ignore the timezone anymore

PHP Version

PHP 5.x-8.4 

Operating System

No response

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