\WP_Stager_Integration\Calendar::calculate_timestamp_week_end(int $year, int $week_number): int

Description

Calculates the end timestamp of a given week (23:59:59 in the current site's timezone, last day of the week).

Takes the site's start_of_week setting into account

Parameters:

ParameterTypeDescription
$year int The year
$week_number int The week number

Returns:

int Unix timestamp for week start (00:00:00)

Information

Fileclass-calendar.php line 724

Full Code

/**
 * Calculates the end timestamp of a given week (23:59:59 in the current site's timezone, last day of the week).
 *
 * Takes the site's <code>start_of_week</code> setting into account
 *
 * @param int $year          The year
 * @param int $week_number   The week number
 *
 * @return int   Unix timestamp for week start (00:00:00)
 */
public static function calculate_timestamp_week_end( $year, $week_number ) {

    // Type casting
    $year        = (int) $year;
    $week_number = (int) $week_number;

    // Get data
    $week_start = (int) (self::calculate_timestamp_week_start( $year, $week_number ) ?: 0);

    // Offset 6 days, 23 hours, 59 minutes, 59 seconds.
    $week_end = self::calculate_offset_timestamp( $week_start, 'P6DT23H59M59S' );

    return $week_end;
}

💡 If you ever get stuck or have a question, please check our FAQs, our Free Integration Service, our paid Full Integration Service, or reach out to us!

Get WP Stager Integration

🎁 Limited offer: Use code WELCOME26 to get your first month for free!