|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #24603 all timefunctions don't give back correct time
Submitted: 2003-07-11 08:01 UTC Modified: 2003-07-11 12:14 UTC
From: akorthaus at web dot de Assigned:
Status: Not a bug Package: Date/time related
PHP Version: 4.3.2 OS: RedHat-Linux 7.3, kernel 2.4.20
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
From: akorthaus at web dot de
New email:
PHP Version: OS:


 [2003-07-11 08:01 UTC] akorthaus at web dot de

Now I'm trying to solve this problem for more then 10 houres,  nad nobody seems to know what is going wrong here. If I try this:

echo date("H:i:s")."\n";
echo gmdate("H:i:s");

That displays:

What I would expect would be the same like date in shell:
# date
Fri Jul 11 13:37:39 CEST 2003

the correspondent Apache access-log:
[11/Jul/2003:12:36:36 +0100]

# /sbin/hwclock
Fri 11 Jul 2003 13:36:42 PM CEST  0.707042 seconds

and it could not be set by
# /sbin/hwclock --systohc --utc
but I think thats not important

# ls -l /etc/localtime
lrwxrwxrwx    1 root     root           33 Jul 11 09:33 /etc/localtime -> /usr/share/zoneinfo/Europe/Berlin

which is what I want(my timezone). It's GMT + 1. PHP _has_ these difference of one hour between time() and gmtime(), but both are an extra hour too late.

I also restartet Apache, I tried to change /etc/sysconfig/clock, which is now:

# cat /etc/sysconfig/clock

But PHP did not take care about changes in it, PHP also did not care about changing my timezone, this 1 hour too late stays.

also ntpdate did not help, the time was changed about 3 seconds.

Im Using RedHat Linux 7.3 min.-Installation
I compiled Apache 1.3.27 with PHP 4.3.2 as static module.

My PHP-./configure:
./configure --with-apache=../apache_1.3.27 --with-mysql --with-gd --with-jpeg-dir=/usr --with-png-dir=/usr --with-ttf --with-zlib --enable-gd-native-ttf --enable-trans-sid --disable-cgi --enable-ftp

I'm using PHP-Accelerator.

I have asked a lot of people and searched for people with similar problems, but I did not find any. So my last Idea is that it's a PHP-Bug.

Reproduce code:
echo date("H:i:s")."\n";
echo gmdate("H:i:s");

Expected result:
date: +-0 hours
gmdate -1 hour

Actual result:
date: -1 hour
gmdate -2 hours


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2003-07-11 10:51 UTC]
We are happy to tell you that you just discovered Daylight Savings
Time. For more information see:
Instead of using mktime/date consider using gmmktime and gmdate which do
not suffer from DST.

Borked system. Works fine here:

18:49:44 EEST
15:49:44 GMT
Fri Jul 11 18:49:44 EEST 2003


echo date("H:i:s T"), "\n";
echo gmdate("H:i:s T"),"\n";
echo exec('date'), "\n";


Remember the DST...

 [2003-07-11 11:25 UTC] akorthaus at web dot de
That's what I get with your code:

17:20:09 BST
16:20:09 GMT
Fri Jul 11 18:20:09 CEST 2003 

No, The Problem is, that PHP doesn't use my local time, it doesn't use CEST as "date" in shell does, it uses BST. Why does PHP use a timezone I nerver used somewhere? Where does PHP get this information from? Or is it set at compile-time?

Because at that time it was BST not, CEST.
 [2003-07-11 11:28 UTC] akorthaus at web dot de
If it was a problem of DST, the output should have been:

17:20:09 CET
16:20:09 GMT
Fri Jul 11 18:20:09 CEST 2003 

CET : Central Europe Time
CEST : Central Europe Summer Time
BST : British Summer Time
 [2003-07-11 12:14 UTC]
Something, somewhere in your system sets the timezone to BST.
I just listed all possible reasons why this is bogus. :)

PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun May 26 09:01:32 2024 UTC