Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

gettimeofday produce different results with 7.4.26 and 8.0.30 #17948

Closed
UB-EW-JordiGuilleumes-proves opened this issue Feb 27, 2025 · 1 comment

Comments

@UB-EW-JordiGuilleumes-proves
Copy link

UB-EW-JordiGuilleumes-proves commented Feb 27, 2025

Description

The following code produce different results depending on the PHP version:

PHP 7.4.26

  • gettimeofday()minuteswest]=>-60
  • date("H") -> 18
php > echo PHP_VERSION;
7.4.26
php > print_r(gettimeofday());
Array
(
    [sec] => 1740678496
    [usec] => 223357
    [minuteswest] => -60
    [dsttime] => 0
)
php > echo date("d-m-Y H:i:s", 1740678496);
27-02-2025 18:48:16
php >

PHP 8.0.30

  • gettimeofday()[minuteswest]=>0
  • date("H") -> 17
php > echo PHP_VERSION;
8.0.30
php > print_r(gettimeofday());
Array
(
    [sec] => 1740678496
    [usec] => 896395
    [minuteswest] => 0
    [dsttime] => 0
)
php > echo date("d-m-Y H:i:s", 1740678496);
27-02-2025 17:48:16
php >

Code executed at the same machine (Win10 64b), almost at the same time (you can see the [usec])..

PHP Version

PHP 8.0.30 and PHP 7.4.26

Operating System

Windows 10 (64b)

@UB-EW-JordiGuilleumes-proves
Copy link
Author

Well, I've been searching a lot, and have found nothing about it, before adding this issue.
And just after sending it, I've found that the problem is in the php.ini:
7.4.26
date.timezone = "Europe/Berlin"
8.0.30
date.timezone = "UTC"

After changing the timezone of the 8.0.30 php.ini, and resetting the PHP:

  • gettimeofday()minuteswest]=>-60
  • date("H") -> 18
php > echo PHP_VERSION;
8.0.30
php > echo date("d-m-Y H:i:s", 1740678496);
27-02-2025 18:48:16
php >

I leave the question and the (auto)answer for other people who stumble upon the problem.

@iluuu1994 iluuu1994 closed this as not planned Won't fix, can't repro, duplicate, stale Feb 27, 2025
# for free to join this conversation on GitHub. Already have an account? # to comment
Projects
None yet
Development

No branches or pull requests

2 participants