question

JoshP-8637 avatar image
0 Votes"
JoshP-8637 asked SnehaAgrawal-MSFT answered

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

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-webapps
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

SnehaAgrawal-MSFT avatar image
1 Vote"
SnehaAgrawal-MSFT answered

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.



· 2
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

We are indeed running on 32 bit, I just checked. The person who set it up said they just used the default settings, we don't have any particular reason to use 32 bit over 64. Are there any major problems we might cause by changing this now as opposed to when it was first setup?

Also thank you for identifying the problem!

0 Votes 0 ·

Thanks for reply! While changing any applications settings (example platform setting) this will restart your application.

When changing any setting please click on save. and you will receive a similar pop-up on application will restart. Once done you will get notification that your settings are updated.

Let us know.

0 Votes 0 ·