bp_core_get_iso8601_date( $timestamp = '' )

Return an ISO-8601 date from a date string.

Description

Parameters

(Required) String of date to convert. Timezone should be UTC before using this.

Return

(string)

Source

File: bp-core/bp-core-functions.php

1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
function bp_core_get_iso8601_date( $timestamp = '' ) {
    if ( ! $timestamp ) {
        return '';
    }
 
    try {
        $date = new DateTime( $timestamp, new DateTimeZone( 'UTC' ) );
 
    // Not a valid date, so return blank string.
    } catch( Exception $e ) {
        return '';
    }
 
    return $date->format( DateTime::ISO8601 );
}

Changelog

Changelog
Version Description
BuddyPress 2.7.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.