Title: WP_Community_Events::format_event_data_time
Published: June 15, 2017
Last modified: May 20, 2026

---

# WP_Community_Events::format_event_data_time( array $response_body ): array

## In this article

 * [Description](https://developer.wordpress.org/reference/classes/wp_community_events/format_event_data_time/?output_format=md#description)
 * [Parameters](https://developer.wordpress.org/reference/classes/wp_community_events/format_event_data_time/?output_format=md#parameters)
 * [Return](https://developer.wordpress.org/reference/classes/wp_community_events/format_event_data_time/?output_format=md#return)
 * [Source](https://developer.wordpress.org/reference/classes/wp_community_events/format_event_data_time/?output_format=md#source)
 * [Related](https://developer.wordpress.org/reference/classes/wp_community_events/format_event_data_time/?output_format=md#related)
 * [Changelog](https://developer.wordpress.org/reference/classes/wp_community_events/format_event_data_time/?output_format=md#changelog)

[ Back to top](https://developer.wordpress.org/reference/classes/wp_community_events/format_event_data_time/?output_format=md#wp--skip-link--target)

This method has been deprecated since 5.5.2. No longer used in core instead.

Adds formatted date and time items for each event in an API response.

## 󠀁[Description](https://developer.wordpress.org/reference/classes/wp_community_events/format_event_data_time/?output_format=md#description)󠁿

This has to be called after the data is pulled from the cache, because the cached
events are shared by all users. If it was called before storing the cache, then 
all users would see the events in the localized data/time of the user who triggered
the cache refresh, rather than their own.

## 󠀁[Parameters](https://developer.wordpress.org/reference/classes/wp_community_events/format_event_data_time/?output_format=md#parameters)󠁿

 `$response_body`arrayrequired

The response which contains the events.

## 󠀁[Return](https://developer.wordpress.org/reference/classes/wp_community_events/format_event_data_time/?output_format=md#return)󠁿

 array The response with dates and times formatted.

## 󠀁[Source](https://developer.wordpress.org/reference/classes/wp_community_events/format_event_data_time/?output_format=md#source)󠁿

    ```php
    protected function format_event_data_time( $response_body ) {
    	_deprecated_function( __METHOD__, '5.5.2' );

    	if ( isset( $response_body['events'] ) ) {
    		foreach ( $response_body['events'] as $key => $event ) {
    			$timestamp = strtotime( $event['date'] );

    			/*
    			 * The `date_format` option is not used because it's important
    			 * in this context to keep the day of the week in the formatted date,
    			 * so that users can tell at a glance if the event is on a day they
    			 * are available, without having to open the link.
    			 */
    			/* translators: Date format for upcoming events on the dashboard. Include the day of the week. See https://www.php.net/manual/datetime.format.php */
    			$formatted_date = date_i18n( __( 'l, M j, Y' ), $timestamp );
    			$formatted_time = date_i18n( get_option( 'time_format' ), $timestamp );

    			if ( isset( $event['end_date'] ) ) {
    				$end_timestamp      = strtotime( $event['end_date'] );
    				$formatted_end_date = date_i18n( __( 'l, M j, Y' ), $end_timestamp );

    				if ( 'meetup' !== $event['type'] && $formatted_end_date !== $formatted_date ) {
    					/* translators: Upcoming events month format. See https://www.php.net/manual/datetime.format.php */
    					$start_month = date_i18n( _x( 'F', 'upcoming events month format' ), $timestamp );
    					$end_month   = date_i18n( _x( 'F', 'upcoming events month format' ), $end_timestamp );

    					if ( $start_month === $end_month ) {
    						$formatted_date = sprintf(
    							/* translators: Date string for upcoming events. 1: Month, 2: Starting day, 3: Ending day, 4: Year. */
    							__( '%1$s %2$d–%3$d, %4$d' ),
    							$start_month,
    							/* translators: Upcoming events day format. See https://www.php.net/manual/datetime.format.php */
    							date_i18n( _x( 'j', 'upcoming events day format' ), $timestamp ),
    							date_i18n( _x( 'j', 'upcoming events day format' ), $end_timestamp ),
    							/* translators: Upcoming events year format. See https://www.php.net/manual/datetime.format.php */
    							date_i18n( _x( 'Y', 'upcoming events year format' ), $timestamp )
    						);
    					} else {
    						$formatted_date = sprintf(
    							/* translators: Date string for upcoming events. 1: Starting month, 2: Starting day, 3: Ending month, 4: Ending day, 5: Year. */
    							__( '%1$s %2$d – %3$s %4$d, %5$d' ),
    							$start_month,
    							date_i18n( _x( 'j', 'upcoming events day format' ), $timestamp ),
    							$end_month,
    							date_i18n( _x( 'j', 'upcoming events day format' ), $end_timestamp ),
    							date_i18n( _x( 'Y', 'upcoming events year format' ), $timestamp )
    						);
    					}

    					$formatted_date = wp_maybe_decline_date( $formatted_date, 'F j, Y' );
    				}
    			}

    			$response_body['events'][ $key ]['formatted_date'] = $formatted_date;
    			$response_body['events'][ $key ]['formatted_time'] = $formatted_time;
    		}
    	}

    	return $response_body;
    }
    ```

[View all references](https://developer.wordpress.org/reference/files/wp-admin/includes/class-wp-community-events.php/)
[View on Trac](https://core.trac.wordpress.org/browser/tags/7.0/src/wp-admin/includes/class-wp-community-events.php#L383)
[View on GitHub](https://github.com/WordPress/wordpress-develop/blob/7.0/src/wp-admin/includes/class-wp-community-events.php#L383-L442)

## 󠀁[Related](https://developer.wordpress.org/reference/classes/wp_community_events/format_event_data_time/?output_format=md#related)󠁿

| Uses | Description | 
| [wp_maybe_decline_date()](https://developer.wordpress.org/reference/functions/wp_maybe_decline_date/)`wp-includes/functions.php` |

Determines if the date should be declined.

  | 
| [date_i18n()](https://developer.wordpress.org/reference/functions/date_i18n/)`wp-includes/functions.php` |

Retrieves the date in localized format, based on a sum of Unix timestamp and timezone offset in seconds.

  | 
| [__()](https://developer.wordpress.org/reference/functions/__/)`wp-includes/l10n.php` |

Retrieves the translation of $text.

  | 
| [_x()](https://developer.wordpress.org/reference/functions/_x/)`wp-includes/l10n.php` |

Retrieves translated string with gettext context.

  | 
| [_deprecated_function()](https://developer.wordpress.org/reference/functions/_deprecated_function/)`wp-includes/functions.php` |

Marks a function as deprecated and inform when it has been used.

  | 
| [get_option()](https://developer.wordpress.org/reference/functions/get_option/)`wp-includes/option.php` |

Retrieves an option value based on an option name.

  |

[Show 4 more](https://developer.wordpress.org/reference/classes/wp_community_events/format_event_data_time/?output_format=md#)
[Show less](https://developer.wordpress.org/reference/classes/wp_community_events/format_event_data_time/?output_format=md#)

## 󠀁[Changelog](https://developer.wordpress.org/reference/classes/wp_community_events/format_event_data_time/?output_format=md#changelog)󠁿

| Version | Description | 
| [5.5.2](https://developer.wordpress.org/reference/since/5.5.2/) | Deprecated. No longer used in core. | 
| [4.8.0](https://developer.wordpress.org/reference/since/4.8.0/) | Introduced. |

## User Contributed Notes

You must [log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Fclasses%2Fwp_community_events%2Fformat_event_data_time%2F)
before being able to contribute a note or feedback.