registry =& $registry; $this->servertz = date('Z', TIMENOW) / 3600; } // ################################################################### /** * (PHP 4) Constructor */ function Date(&$registry) { $this->__construct($registry); } // ################################################################### /** * Sets the user timezone variable * * @access public * * @param integer User time zone */ function setUserTimezone($tz) { $this->usertz = $tz; } // ################################################################### /** * Gets the user timezone variable * * @access public * * @return integer The user timezone */ function getUserTimezone() { return $this->usertz; } // ################################################################### /** * Computes the total offset, taking into account all the various * options * * @access public */ function fetch_offset() { $this->offsettz = $this->servertz - $this->usertz; $this->offset = $this->offsettz * 3600; } // ################################################################### /** * Formats a UNIX timestamp to a certain date format in the proper time * zone * * @access public * * @param string Format of the date (same as PHP's date() function) * @param integer UNIX timestamp to format * @param bool Adjust the date to the user's language? * * @return string Formatted date */ function format($format, $timestamp = TIMENOW, $adjust = true) { if ($adjust) { $timestamp -= $this->offset; } return date($format, $timestamp); } // ################################################################### /** * Fetches an array of timezones for a