public function convertTimezone(DateTimeZone $fromTimezone, DateTimeZone $toTimezone = NULL) {
    $toTimezone = !empty($toTimezone) ? $toTimezone : new DateTimeZone($this->siteTimezone);
    $this->convertedTimezone = $fromTimezone;
    $new_date = new DateTime();
    $timestamp = $this->getDate()->getTimestamp() + $fromTimezone->getOffset($this->getDate());
    $new_date->setTimestamp($timestamp);
    $new_date->setTimezone($toTimezone);
    $this->date = $new_date;
    return $new_date;
  }
public function convertTimezone(DateTimeZone $fromTimezone, DateTimeZone $toTimezone = NULL) {
    $toTimezone = !empty($toTimezone) ? $toTimezone : new DateTimeZone($this->siteTimezone);
    $this->convertedTimezone = $fromTimezone;
    $new_date = new DateTime();
    $timestamp = $this->getDate()->getTimestamp() + $fromTimezone->getOffset($this->getDate());
    $new_date->setTimestamp($timestamp);
    $new_date->setTimezone($toTimezone);
    $this->date = $new_date;
    return $new_date;
  }
public function convertTimezone ( DateTimeZone $ fromTimezone , DateTimeZone $ toTimezone = NULL ) { $ toTimezone = ! empty ( $ toTimezone ) ? $ toTimezone : new DateTimeZone ( $ this -> siteTimezone ) ; $ this -> convertedTimezone = $ fromTimezone ; $ new_date = new DateTime ( ) ; $ timestamp = $ this -> getDate ( ) -> getTimestamp ( ) + $ fromTimezone -> getOffset ( $ this -> getDate ( ) ) ; $ new_date -> setTimestamp ( $ timestamp ) ; $ new_date -> setTimezone ( $ toTimezone ) ; $ this -> date = $ new_date ; return $ new_date ; }
Sets the utc date from one timezone to another, defaulting to site default.

This function is useful to convert a date converted to another timezone
back into the site default, but can be used to convert a timezone to
any timezone.

@param \DateTimeZone $fromTimezone
The timezone to convert the UTC date from.

@param \DateTimeZone|null $toTimezone
The timezone to convert the UTC date to.

@return \DateTime
Sets the utc date from one timezone to another defaulting to site default .