php strtotime() with date 12/31/9999 returns false

Josh P 1 Reputation point
2022-04-25T20:16:34.087+00:00

We have a php webapp hosted on an Azure app service, running php version 7.4. We had the same code on a different host a few months ago. On the previous host, php's strtotime() function with the input of '12/31/9999' would return a timestamp, as expected. On Azure, the same code returns false.

Here is a boiled-down snippet of the code:

echo strtotime('12/31/9999');

The output should be "253402214400", which can be verified on any code sandbox, including w3schools.com's online editor. Does anyone know of a configuration/setting somewhere in Azure that might be causing this to return false on their app service?

Azure App Service
Azure App Service
Azure App Service is a service used to create and deploy scalable, mission-critical web apps.
6,922 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. SnehaAgrawal-MSFT 18,366 Reputation points
    2022-04-27T09:11:41.933+00:00

    Thanks for reaching here. Could you please confirm if the worker is running in 32 bit mode, you may be limited on what dates can be used due to the resulting integer size.

    You can check this via Configuration > General settings > Platform settings > Platform : 32 bit/64 bit.

    196931-demotest-microsoft-azure.png

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

    The valid range of a timestamp is typically from Fri, 13 Dec 1901 20:45:54 UTC to Tue, 19 Jan 2038 03:14:07 UTC. (These are the dates that correspond to the minimum and maximum values for a 32-bit signed integer.)

    For 64-bit versions of PHP, the valid range of a timestamp is effectively infinite, as 64 bits can represent approximately 293 billion years in either direction.

    Also could you confirm if it works for a earlier date?

    Let us know.

    1 person found this answer helpful.