note 48546 deleted from function.time by aidan

From: Date: Sat, 08 Oct 2005 01:04:13 +0000
Subject: note 48546 deleted from function.time by aidan
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-96617@lists.php.net to get a copy of this message
Note Submitter: webmaster at protonage dot net ---- Many people have asked me what's an easy way to implement time-stamp time-zone offsets. Here's a simple class I made that has a function that returns a time-stamp calculated with a time-zone offset argument. <?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(); } } $time = new MyTimeZone(); echo date('h:i:s a', $time->timeOffset(-8)); // finds GMT -8 ?> cheers.

« previous php.notes (#96617) next »