BP_XProfile_Field_Type_Datebox::display_filter( string $field_value, string|int $field_id = '' )

Format Date values for display.


Parameters Parameters

$field_value

(string) (Required) The date value, as saved in the database. Typically, this is a MySQL-formatted date string (Y-m-d H:i:s).

$field_id

(string|int) (Optional) ID of the field.

Default value: ''


Top ↑

Return Return

(string) Date formatted by bp_format_time().


Source Source

File: bp-xprofile/classes/class-bp-xprofile-field-type-datebox.php

	public static function display_filter( $field_value, $field_id = '' ) {
		if ( ! $field_value ) {
			return $field_value;
		}

		// If Unix timestamp.
		if ( ! is_numeric( $field_value ) ) {
			$field_value = strtotime( $field_value );
		}

		$settings = self::get_field_settings( $field_id );

		switch ( $settings['date_format'] ) {
			case 'elapsed' :
				$formatted = bp_core_time_since( $field_value );
			break;

			case 'age' :
				$formatted = bp_core_time_old( $field_value );
			break;

			case 'custom' :
				$formatted = date_i18n( $settings['date_format_custom'], $field_value );
			break;

			default :
				$formatted = date_i18n( $settings['date_format'], $field_value );
			break;
		}

		return $formatted;
	}


Top ↑

Changelog Changelog

Changelog
Version Description
2.4.0 Added the $field_id parameter.
2.1.0 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

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