WP_Privacy_Requests_Table::get_timestamp_as_date( int $timestamp ): string

In this article

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 sprintf(
		/* translators: 1: privacy request date format, 2: privacy request time format. */
		__( '%1$s at %2$s' ),
		/* translators: privacy request date format. See https://www.php.net/manual/en/datetime.format.php */
		date_i18n( __( 'Y/m/d' ), $timestamp ),
		/* translators: privacy request time format. See https://www.php.net/manual/en/datetime.format.php */
		date_i18n( __( 'g:i a' ), $timestamp )
	);
}

Changelog

VersionDescription
4.9.6Introduced.

User Contributed Notes

You must log in before being able to contribute a note or feedback.