<?php defined('ABSPATH') || exit; class WC_DateTime extends DateTime { protected $utc_offset = 0; public function __toString() { return $this->format(DATE_ATOM); } public function set_utc_offset($offset) { $this->utc_offset = intval($offset); } public function getOffset() { return $this->utc_offset ? $this->utc_offset : parent::getOffset(); } public function setTimezone($timezone) { $this->utc_offset = 0; return parent::setTimezone($timezone); } public function getTimestamp() { return method_exists('DateTime', 'getTimestamp') ? parent::getTimestamp() : $this->format('U'); } public function getOffsetTimestamp() { return $this->getTimestamp() + $this->getOffset(); } public function date($format) { return gmdate($format, $this->getOffsetTimestamp()); } public function date_i18n($format = 'Y-m-d') { return date_i18n($format, $this->getOffsetTimestamp()); } }