diff --git a/classes/class-date-interval.php b/classes/class-date-interval.php index abcf4601f..0a8494b7b 100644 --- a/classes/class-date-interval.php +++ b/classes/class-date-interval.php @@ -41,13 +41,16 @@ public function get_predefined_intervals() { if ( false === $timezone ) { $timezone = timezone_name_from_abbr( '', $gmt_offset * 3600, false ); } - if ( false === $timezone ) { - $timezone = null; - } } try { - $today = new \DateTimeImmutable( 'today', new \DateTimeZone( $timezone ) ); + $timezone_object = $timezone ? new \DateTimeZone( $timezone ) : null; + } catch ( \Exception $e ) { + $timezone_object = null; + } + + try { + $today = new \DateTimeImmutable( 'today', $timezone_object ); $date_intervals = array( 'today' => array( 'label' => esc_html__( 'Today', 'stream' ), @@ -121,7 +124,7 @@ public function get_predefined_intervals() { } /** - * Allow other plugins to filter the predefined date intervals + * Allow other plugins to filter the predefined date intervals. * * @param array $date_intervals Date intervals array. * @param string $timezone Timezone.