php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #22935 Date function is 16 hours off
Submitted: 2003-03-27 15:29 UTC Modified: 2003-03-27 16:23 UTC
From: james_clent at splwg dot com Assigned:
Status: Not a bug Package: Date/time related
PHP Version: 4.3.0 OS: WIN2000
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.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: james_clent at splwg dot com
New email:
PHP Version: OS:

 

 [2003-03-27 15:29 UTC] james_clent at splwg dot com
When doing this simple function date("H:i:s",1) php returns 16:00:01. Testing with other values still finds this issue.
Haven't seen this as reported out there so assume 4.3.1 has same bug still.
Thank you,
James

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2003-03-27 15:42 UTC] rasmus@php.net
You probably want gmdate() if you are expecting it to return the GMT epoch
 [2003-03-27 16:05 UTC] james_clent at splwg dot com
No that is not what I want. I do exactly what I want to do and expect to get back 0:00:01 as it should.
When I give DATE("H:i:s", 3600) it returns 17:00:00.
I'm trying to display the elapse time between to timestamps (standard UNIX MKTIME values). I just simplified your error for you, because the difference in MKTIME timestamps is in seconds.
 [2003-03-27 16:12 UTC] rasmus@php.net
Well, your expectation is wrong.  Unix timestamps, which is what you are using, are timezone neutral.  That means that a timestamp of 3600 refers to the same moment in history, not the same time.  Therefore date("H:i:s",3600) is going to give you a different answer depending on which timezone you are in.
 [2003-03-27 16:19 UTC] james_clent at splwg dot com
Granted, gndate() gave me the expected results.
 [2003-03-27 16:23 UTC] james_clent at splwg dot com
Your solution is right. However, one might consider to remove this piece of user contribution from the MKTIME function entry though, since it only works if you are on GMT.
------------------<direct copy from webpage>---------------
User Contributed Notes
mktime   
chris at ixi dot net
22-Jul-1999 01:00   
 
You have 74788 seconds and you want to convert to hh:mm:ss.  You can just do date("H:i:s", mktime(0,0,74788))  which returns 20:46:28. 
------------------<end of copy from webpage>---------------
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat May 18 11:01:34 2024 UTC