\WP_Stager_Integration\Calendar::get_year_number(int $timestamp = null): int
\WP_Stager_Integration\Calendar::get_year_number(int $timestamp = null): intDescription
Get a formatted year number. Takes the site's timezone setting into account.
Returns the ISO 8601 week-numbering year. This has the same value as PHP's date('Y'), except that if the ISO week number (W) belongs to the previous or next year, that year is used instead.
Parameters:
| Parameter | Type | Description |
|---|---|---|
$timestamp | int | (Optional) The Unix timestamp to get the number for. Defaults to current server time. |
Returns:
int The year number
Information
| File | class-calendar.php line 188 |
|---|
Full Code
/**
* Get a formatted year number. Takes the site's timezone setting into account.
*
* Returns the ISO 8601 week-numbering year. This has the same value as PHP's <code>date('Y')</code>, except that if the ISO week number (W) belongs to the previous or next year, that year is used instead.
*
* @param int $timestamp (Optional) The Unix timestamp to get the number for. Defaults to current server time.
*
* @return int The year number
*/
public static function get_year_number( $timestamp = null ) {
// Type casting
$timestamp = (int) ($timestamp ?: time());
return (int) wp_date( 'o', $timestamp ); // ISO 8601 week-numbering year. This has the same value as Y, except that if the ISO week number (W) belongs to the previous or next year, that year is used instead.
}💡 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!

