Tribe__Date_Utils::round_nearest_half_hour( string $date )

Returns as string the nearest half a hour for a given valid string datetime.


Parameters

$date

(string) (Required) Valid DateTime string.


Top ↑

Return

(string) Rounded datetime string


Top ↑

Source

File: src/Tribe/Date_Utils.php

		public static function round_nearest_half_hour( $date ) {
			$date_object = static::build_date_object( $date );
			$rounded_minutes = floor( $date_object->format( 'i' ) / 30 ) * 30;

			return $date_object->format( 'Y-m-d H:' ) . $rounded_minutes . ':00';
		}

Top ↑

Changelog

Changelog
Version Description
4.10.2 Introduced.