php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #28705 gmdate and date odd behaivour
Submitted: 2004-06-09 03:30 UTC Modified: 2004-06-09 09:40 UTC
From: ransico at iinet dot net dot au Assigned:
Status: Not a bug Package: Date/time related
PHP Version: Irrelevant OS: windows, unix
Private report: No CVE-ID: None
 [2004-06-09 03:30 UTC] ransico at iinet dot net dot au
Description:
------------
Hi,

I have been tearing my hair out about this - until I discovered the underlying problem when I wrote the test code below.

The problem occurs in version 4, aswell as the latest v5 CVS. I have tried on redhat linux and windows XP. 

When the server is in a non GMT timezone, you would expect gmdate and date to produce different times - and they normally do so. however, when you ask the format to be 'U' (timestamp), gmdate appears to produce the incorrect result - it does NOT take into account that it is supposed to make a GMT result.

The code I attached shows the contradiction in the results of gmdate and date, when using a timestamp, and normal formatting.

Note, the anomolies only appear in timestamps.

Is this intentional? if so, it is very odd behaivour.

Reproduce code:
---------------
print "<br>" . gmdate('U');
print "<br>" . date('U');
print "<br>" . gmdate('g:ia \o\n D d<\sup>S</\sup> M, Y');
print "<br>" . date('g:ia \o\n D d<\sup>S</\sup> M, Y');

Expected result:
----------------
1086707744
1086743744
1:15am on Wed 09th Jun, 2004
11:15am on Wed 09th Jun, 2004

Actual result:
--------------
1086743744
1086743744
1:15am on Wed 09th Jun, 2004
11:15am on Wed 09th Jun, 2004

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2004-06-09 09:40 UTC] derick@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php

Unix Timestamps are always in GMT, so this is the expected behavior.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu May 02 19:01:29 2024 UTC