WP_Privacy_Requests_Table::get_timestamp_as_date() WordPress Method

The WP_Privacy_Requests_Table::get_timestamp_as_date() method is used to get the timestamp of a privacy request as a date. This is useful for displaying the date on which a request was made.

WP_Privacy_Requests_Table::get_timestamp_as_date( int $timestamp ) #

Convert timestamp for display.


Parameters

$timestamp

(int)(Required)Event timestamp.


Top ↑

Return

(string) Human readable date.


Top ↑

Source

File: wp-admin/includes/class-wp-privacy-requests-table.php

	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 );
	}


Top ↑

Changelog

Changelog
VersionDescription
4.9.6Introduced.

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by theĀ Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.