php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #31337 Request for new GMT timezone offset argument for the time() function
Submitted: 2004-12-29 19:12 UTC Modified: 2005-07-04 09:55 UTC
Votes:1
Avg. Score:5.0 ± 0.0
Reproduced:0 of 0 (0.0%)
From: webmaster at protonage dot net Assigned: derick (profile)
Status: Closed Package: Feature/Change Request
PHP Version: 5.1x OS: FreeBSD 4.10
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: webmaster at protonage dot net
New email:
PHP Version: OS:

 

 [2004-12-29 19:12 UTC] webmaster at protonage dot net
Description:
------------
This is just a simple request for a feature of the built in time() for PHP or a new function completely.

I think a timezone offset argument for this function would be great. Let's say I want to find the GMT -6 but my server is located in GMT -8, here is an example pice of what the function should automaticly do: (see attached code)

The function simply returns a timestamp of the offset provided in the argument, would be nice to have such an argument exist in the time() function, or a whole new function if adding an argument to time() isn't possiable.

Reproduce code:
---------------
<?php
class MyTimeZone {
   const TIMEZONE_SERVER_OFFSET = -5; // your server's offset from GMT 0
   public function timeOffset($offset = null)
   {
       if (is_int($offset)) {
           $local_offset = $offset - self::TIMEZONE_SERVER_OFFSET;
           return time() + 3600 * $local_offset;
       }
       return time();
   }
}
// Current time in my server's location is 1:07 pm GMT -5
$time = new MyTimeZone();
echo date('h:i:s a', $time->timeOffset(-8)); // finds GMT -8
// The result would look something like this:
// 10:07:42 am
?>


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2004-12-29 20:13 UTC] derick@php.net
This is on the list for 5.1.
 [2005-07-04 09:55 UTC] derick@php.net
This bug has been fixed in CVS.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.
 
Thank you for the report, and for helping us make PHP better.

You can now use the date_timezone_set() function in PHP 5.1-dev to set the timezone you want to be in. You need to use a full Timezone Identifier for this, such as America/New_York, or America/Los_Angeles.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Oct 17 16:01:28 2024 UTC