\WP_Stager_Integration\Calendar::calculate_timestamp_month_end(int $year, int $month): int

Description

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

Parameters:

ParameterTypeDescription
$year int The year
$month int The month (1-12)

Returns:

int Unix timestamp for month end

Information

Fileclass-calendar.php line 765

Full Code

/**
 * Calculates the end timestamp of a given month (23:59:59 in the current site's timezone, last day of the month).
 *
 * @param int $year     The year
 * @param int $month    The month (1-12)
 *
 * @return int   Unix timestamp for month end
 */
public static function calculate_timestamp_month_end( $year, $month ) {

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

    // Get month start
    $month_start           = self::calculate_timestamp_month_start( $year, $month );
    $date_string_month_end = wp_date( 'Y-m-t 23:59:59', $month_start ); // 't' returns the number of days in the month (28-31), which equals the last day of the month

    return self::calculate_local_timestamp( $date_string_month_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!