BP_XProfile_Field_Type_Datebox::display_filter( string $field_value, string|int $field_id = '' )
Format Date values for display.
Description
Parameters
- $field_value
-
(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
-
(Optional) ID of the field.
Default value: ''
Return
(string) Date formatted by bp_format_time().
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 'custom' :
$formatted = date_i18n( $settings['date_format_custom'], $field_value );
break;
default :
$formatted = date_i18n( $settings['date_format'], $field_value );
break;
}
return $formatted;
}
Changelog
| Version | Description |
|---|---|
| BuddyPress 2.1.0 | Introduced. |
Questions?
We're always happy to help with code or other questions you might have! Search our developer docs, contact support, or connect with our sales team.