#31337 [Asn->Csd]: Request for new GMT timezone offset argument for the time() function

From: Date: Mon, 04 Jul 2005 07:55:29 +0000
Subject: #31337 [Asn->Csd]: Request for new GMT timezone offset argument for the time() function
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-81353@lists.php.net to get a copy of this message
ID: 31337 Updated by: derick@php.net Reported By: webmaster at protonage dot net -Status: Assigned +Status: Closed Bug Type: Feature/Change Request Operating System: FreeBSD 4.10 PHP Version: 5.1x Assigned To: derick New Comment: 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. Previous Comments: ------------------------------------------------------------------------ [2004-12-29 20:13:52] derick@php.net This is on the list for 5.1. ------------------------------------------------------------------------ [2004-12-29 19:12:58] 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 ?> ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=31337&edit=1

« previous php.bugs (#81353) next »