W3cubDocs

/WordPress

WP_Privacy_Requests_Table::get_timestamp_as_date( int $timestamp ): string

Converts a timestamp for display.

Parameters

$timestampintrequired
Event timestamp.

Return

string Human readable date.

Source

protected function get_timestamp_as_date( $timestamp ) {
	if ( empty( $timestamp ) ) {
		return '';
	}

	$time_diff = time() - $timestamp;

	if ( $time_diff >= 0 && $time_diff < DAY_IN_SECONDS ) {
		/* translators: %s: Human-readable time difference. */
		return sprintf( __( '%s ago' ), human_time_diff( $timestamp ) );
	}

	return date_i18n( get_option( 'date_format' ), $timestamp );
}

Changelog

Version Description
4.9.6 Introduced.

© 2003–2024 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/classes/wp_privacy_requests_table/get_timestamp_as_date