\WP_Stager_Integration\Calendar::format_day_label(int $timestamp, array $args = array()): string
\WP_Stager_Integration\Calendar::format_day_label(int $timestamp, array $args = array()): stringDescription
Formats a Unix timestamp into a text label for days in the calendar (e.g. "January 1, 2000").
Uses the site's date_format option as date format.
Parameters:
| Parameter | Type | Description |
|---|---|---|
$timestamp | int | A Unix timestamp |
$args | array | (Optional) Additional arguments passed to the component template. |
Returns:
string A formatted day label
Information
| File | class-calendar.php line 255 |
|---|
Full Code
/**
* Formats a Unix timestamp into a text label for days in the calendar (e.g. "January 1, 2000").
*
* Uses the site's <code>date_format</code> option as date format.
*
* @param int $timestamp A Unix timestamp
* @param array $args (Optional) Additional arguments passed to the component template.
*
* @return string A formatted day label
*/
public static function format_day_label( $timestamp, $args = array() ) {
// Type casting
$timestamp = (int) $timestamp;
$args = (array) $args;
// Get data
$view = (string) ($args[ 'view' ] ?? 'calendar');
switch ( $view ) {
case 'calendar':
$date_format = 'j';
break;
case 'list':
$date_format = 'D j M';
break;
default:
$date_format = (string) (get_option( 'date_format' ) ?: 'F j, Y');
break;
}
// Define default label
$default = wp_date( $date_format, $timestamp );
/**
* Filters the default calendar "day" label text.
*
* @param string $label The label text
* @param int $timestamp A Unix timestamp of the start of the day (00:00:00 in the site's timezone)
* @param array $args Additional arguments passed to the component template.
*
* @return string Must return a string
*/
$label = (string) apply_filters( 'wpstagerintegration_calendar_label_day', $default, $timestamp, $args );
return $label;
}💡 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!

