Automattic\WooCommerce\Admin\API\Reports

TimeInterval::week_number()public staticWC 1.0

Returns ISO 8601 week number for the DateTime, if week starts on Monday, otherwise returns simple week number.

Method of the class: TimeInterval{}

No Hooks.

Return

Int.

Usage

$result = TimeInterval::week_number( $datetime, $first_day_of_week );
$datetime(DateTime) (required)
Local date for which the week number is to be calculated.
$first_day_of_week(int) (required)
0 for Sunday to 6 for Saturday.

Notes

TimeInterval::week_number() code WC 7.3.0

public static function week_number( $datetime, $first_day_of_week ) {
	if ( 1 === $first_day_of_week ) {
		$week_number = (int) $datetime->format( 'W' );
	} else {
		$week_number = self::simple_week_number( $datetime, $first_day_of_week );
	}
	return $week_number;
}