BP_REST_Forums_Endpoint::prepare_date_response( string $date_gmt, string|null $date = null )

Check the post_date_gmt or modified_gmt and prepare any post or modified date for single post output.

Description

Parameters

$date_gmt

(Required) GMT date format.

$date

(Optional) forum date.

Default value: null

Return

(string|null) ISO8601/RFC3339 formatted datetime.

Source

File: bp-forums/classes/class-bp-rest-forums-endpoint.php

1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
public function prepare_date_response( $date_gmt, $date = null ) {
    // Use the date if passed.
    if ( isset( $date ) ) {
        return mysql_to_rfc3339( $date );
    }
 
    // Return null if $date_gmt is empty/zeros.
    if ( '0000-00-00 00:00:00' === $date_gmt ) {
        return null;
    }
 
    // Return the formatted datetime.
    return mysql_to_rfc3339( $date_gmt );
}

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.