|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2004-12-29 20:13 UTC] derick@php.net
[2005-07-04 09:55 UTC] derick@php.net
|
|||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Fri Dec 05 02:00:01 2025 UTC |
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 ?>