huangyz
huangyz

Reputation: 15

Y2038 problem still exists under 64bit Windows+PHP8 environment

system cfg: 64bit notebook with 64bit Win11 Home Edition (x64 MSVC runtime installed) and the latest 64bit PHP8.3.8. After I manually set system time to 2040-01-01, I can't get the "current time" correctly by using time() or datetime::getTimestamp(), both result in (same) negative numbers. But, all other functions about date and time are working normally, for example, strtotime("2040-01-01") outputs the correct integer value bigger than 2^31. My question is: Did I miss something in my system's configuration? Or, it's just a "bug" of microsoft windows? I've heard that Linux doesn't have such kind of problem, but I am sorry I am not familiar with Linux... Thanks advance for any of your anwsers!!

I've tried running/debugging PHP from VS Code(64bit) or just command line but got the same result. I just eager to know whether I did something wrong or some other reasons.

update20240703: I've managed to install a Ubantu VM......yes, it works: screenshot of time()&date()

update20240711: the current PHP installation pack is named php-8.3.8-nts-Win32-vs16-x64.exe, which means it was compiled upon visualstudio2019, which is delivered as a Win32 program only. While the latest VS2022 (launched a few days ago) was built for multiple architectures(x86/x64/arm). I installed VS2022 today (with C++ support only) and run the similar time test, it gets the correct "current timestamp" beyond 2038. So, probable solution of this question is:

  1. just waiting for a new official build of PHP by using of VS17 or later
  2. Self-build PHP from open-source code under VS2022(x64) environment or by using Mingw64 for windows.

Upvotes: -1

Views: 94

Answers (2)

cmb
cmb

Reputation: 715

See https://github.com/php/php-src/issues/17856.

The Visual Studio version used to build PHP shouldn't matter.

Upvotes: 0

huangyz
huangyz

Reputation: 15

the current PHP installation pack is named php-8.3.8-nts-Win32-vs16-x64.exe, which means it was compiled upon visualstudio2019, which is delivered as a Win32 program only. While the latest VS2022 (launched a few days ago) was built for multiple architectures(x86/x64/arm). I installed VS2022 today (with C++ support only) and run the similar time test, it gets the correct "current timestamp" beyond 2038. So, probable solution of this question is:

  1. just waiting for a new official build of PHP by using of VS17 or later
  2. Self-build PHP from open-source code under VS2022(x64) environment or by using Mingw64 for windows.

Upvotes: 0

Related Questions