CMB2_Display_Text_Date_Timezone

The CMB2 CMB2 Display Text Date Timezone class.

Defined (1)

The class is defined in the following location(s).

/includes/CMB2_Field_Display.php  
  1. class CMB2_Display_Text_Date_Timezone extends CMB2_Field_Display { 
  2. /** 
  3. * Display text_datetime_timestamp_timezone value. 
  4. * @since 2.2.2 
  5. */ 
  6. protected function _display() { 
  7. $field = $this->field; 
  8.  
  9. if ( empty( $this->value ) ) { 
  10. return; 
  11.  
  12. $datetime = maybe_unserialize( $this->value ); 
  13. $this->value = $tzstring = ''; 
  14.  
  15. if ( $datetime && $datetime instanceof DateTime ) { 
  16. $tz = $datetime->getTimezone(); 
  17. $tzstring = $tz->getName(); 
  18. $this->value = $datetime->getTimestamp(); 
  19.  
  20. $date = $this->field->get_timestamp_format( 'date_format', $this->value ); 
  21. $time = $this->field->get_timestamp_format( 'time_format', $this->value ); 
  22.  
  23. echo $date, ( $time ? ' ' . $time : '' ), ( $tzstring ? ', ' . $tzstring : '' );