tribe_beginning_of_day( string|null $date = null, string $format = 'Y-m-d H:i:s' )

Returns formatted date for the official beginning of the day according to the Multi-day cutoff time option


Parameters

$date

(string|null) (Optional) The date to find the beginning of the day, defaults to today

Default value: null

$format

(string) (Optional) Allows date and time formatting using standard php syntax. ( see: <a href="http://php.net/manual/en/function.date.php">http://php.net/manual/en/function.date.php</a> ) Defaults to 'Y-m-d H:i:s'.

Default value: 'Y-m-d H:i:s'


Top ↑

Return

(string)


Top ↑

Source

File: src/functions/template-tags/date.php

	function tribe_beginning_of_day( $date = null, $format = 'Y-m-d H:i:s' ) {
		$multiday_cutoff = explode( ':', tribe_get_option( 'multiDayCutoff', '00:00' ) );
		$hours_to_add    = $multiday_cutoff[0];
		$minutes_to_add  = $multiday_cutoff[1];
		if ( is_null( $date ) || empty( $date ) ) {
			$date = date( $format, strtotime( date( 'Y-m-d' ) . ' +' . $hours_to_add . ' hours ' . $minutes_to_add . ' minutes' ) );
		} else {
			$date      = Tribe__Date_Utils::is_timestamp( $date ) ? $date : strtotime( $date );
			$timestamp = strtotime( date( 'Y-m-d', $date ) . ' +' . $hours_to_add . ' hours ' . $minutes_to_add . ' minutes' );
			$date      = date( $format, $timestamp );
		}

		/**
		 * Deprecated filter tribe_event_beginning_of_day in 4.0 in favor of tribe_beginning_of_day. Remove in 5.0
		 */
		$date = apply_filters( 'tribe_event_beginning_of_day', $date );

		/**
		 * Filters the beginning of day date
		 *
		 * @param string $date
		 */
		return apply_filters( 'tribe_beginning_of_day', $date );
	}