tribe_get_days_between( string $start_date, string $end_date, string|bool $day_cutoff = '00:00' )
Accepts two dates and returns the number of days between them
Contents
See also
Parameters
- $start_date
-
(string) (Required)
- $end_date
-
(string) (Required)
- $day_cutoff
-
(string|bool) (Optional)
Default value: '00:00'
Return
(int)
Source
File: src/functions/template-tags/general.php
function tribe_get_days_between( $start_date, $end_date, $day_cutoff = '00:00' ) { if ( $day_cutoff === false ) { $day_cutoff = '00:00'; } elseif ( $day_cutoff === true ) { $day_cutoff = tribe_get_option( 'multiDayCutoff', '00:00' ); } $start_date = new DateTime( $start_date ); if ( $start_date < new DateTime( $start_date->format( 'Y-m-d ' . $day_cutoff ) ) ) { $start_date->modify( '-1 day' ); } $end_date = new DateTime( $end_date ); if ( $end_date <= new DateTime( $end_date->format( 'Y-m-d ' . $day_cutoff ) ) ) { $end_date->modify( '-1 day' ); } return Tribe__Date_Utils::date_diff( $start_date->format( 'Y-m-d ' . $day_cutoff ), $end_date->format( 'Y-m-d ' . $day_cutoff ) ); }