Tribe__Date_Utils::get_first_day_of_week_in_month( int $curdate, int $day_of_week )
Gets the first day of the week in a month (ie the first Tuesday).
Contents
Parameters
- $curdate
-
(int) (Required) A timestamp.
- $day_of_week
-
(int) (Required) The index of the day of the week.
Return
(int) The timestamp of the date that fits the qualifications.
Source
File: src/Tribe/Date_Utils.php
public static function get_first_day_of_week_in_month( $curdate, $day_of_week ) {
$nextdate = mktime( 0, 0, 0, date( 'n', $curdate ), 1, date( 'Y', $curdate ) );
while ( ! ( $day_of_week > 0 && date( 'N', $nextdate ) == $day_of_week ) &&
! ( $day_of_week == - 1 && self::is_weekday( $nextdate ) ) &&
! ( $day_of_week == - 2 && self::is_weekend( $nextdate ) ) ) {
$nextdate = strtotime( date( self::DBDATETIMEFORMAT, $nextdate ) . ' + 1 day' );
}
return $nextdate;
}