1 date.class.inc | public BackdropDateTime::setTimezone($timezone, $force = FALSE) |
File
- core/
includes/ date.class.inc, line 219
Class
- BackdropDateTime
- Extends PHP DateTime class for use with Backdrop.
Code
public function setTimezone($timezone, $force = FALSE) {
if (!$this->hasTime() || !$this->hasGranularity('timezone') || $force) {
// This has no time or timezone granularity, so timezone doesn't mean
// much. We set the timezone using the method, which will change the
// day/hour, but then we switch back.
$arr = $this->toArray(TRUE);
parent::setTimezone($timezone);
$this->setDate($arr['year'], $arr['month'], $arr['day']);
$this->setTime($arr['hour'], $arr['minute'], $arr['second']);
$this->addGranularity('timezone');
return $this;
}
return parent::setTimezone($timezone);
}