/** * @param $datetime * @return string * @throws EE_Error */ private function _convert_from_string_value_to_utc_unix_timestamp($datetime) { //create a new datetime object using the given string and timezone $this->_set_date_obj($datetime, $this->_timezone); if (!$this->_date instanceof DateTime && !$this->_nullable) { throw new EE_Error(__('Something went wrong with setting the date/time. Likely, either there is an invalid datetime string or an invalid timezone string being used.', 'event_espresso')); } $this->_date->setTimezone(EE_Datetime_Field::get_UTC_DateTimeZone()); return $this->_date->format('U'); }
/** * See $_timezone property for description of what the timezone property is for. This SETS the timezone internally for being able to reference what timezone we are running conversions on when converting TO the internal timezone (UTC Unix Timestamp) for the object OR when converting FROM the internal timezone (UTC Unix Timestamp). * This is available to all child classes that may be using the EE_Datetime_Field for a field data type. * * @access public * @param string $timezone A valid timezone string as described by @link http://www.php.net/manual/en/timezones.php * @return void */ public function set_timezone($timezone = '') { $timezone = empty($timezone) ? get_option('timezone_string') : $timezone; //if timezone is STILL empty then let's get the GMT offset and then set the timezone_string using our converter if (empty($timezone)) { //let's get a the WordPress UTC offset $offset = get_option('gmt_offset'); $timezone = EE_Datetime_Field::timezone_convert_to_string_from_offset($offset); } EE_Datetime_Field::validate_timezone($timezone); //just running validation on the timezone. $this->_timezone = $timezone; //make sure we clear all cached properties because they won't be relevant now $this->_clear_cached_properties(); }
public function __construct($table_column, $nice_name, $nullable, $default_value, $timezone = NULL, $date_format = NULL, $time_format = NULL, $pretty_date_format = NULL, $pretty_time_format = NULL) { parent::__construct($table_column, $nice_name, $nullable, $default_value, $timezone, $date_format, $time_format, $pretty_date_format, $pretty_time_format); }