Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
08/10/2016 12:55:49 PM (9 years ago)
Author:
djpaul
Message:

Fix inaccurate timestamps caused by page caching.

If any template with a timestamp is statically cached, then the timestamps quickly become inaccurate.
The change adds livestamp.js and moment.js to dynamically update timestamps with the real relative time.

A consequence is that the labels surrounding the timestamps, notably in our widgets, have slightly changed.
We're going to keep an eye on this for the remainder of the 2.7 development cycle, and may make further adjustments as testing proves necessary.

Fixes #5757

Props r-a-y, imath, DJPaul

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/bp-core/bp-core-functions.php

    r10972 r11008  
    12591259}
    12601260
     1261/**
     1262 * Output an ISO-8601 date from a date string.
     1263 *
     1264 * @since 2.7.0
     1265 *
     1266 * @param string String of date to convert. Timezone should be UTC before using this.
     1267 * @return string
     1268 */
     1269 function bp_core_iso8601_date( $timestamp = '' ) {
     1270    echo bp_core_get_iso8601_date( $timestamp );
     1271}
     1272    /**
     1273     * Return an ISO-8601 date from a date string.
     1274     *
     1275     * @since 2.7.0
     1276     *
     1277     * @param string String of date to convert. Timezone should be UTC before using this.
     1278     * @return string
     1279     */
     1280     function bp_core_get_iso8601_date( $timestamp = '' ) {
     1281        if ( ! $timestamp ) {
     1282            return '';
     1283        }
     1284
     1285        $date = new DateTime( $timestamp, new DateTimeZone( 'UTC' ) );
     1286        return $date->format( DateTime::ISO8601 );
     1287    }
     1288
    12611289/** Messages ******************************************************************/
    12621290
Note: See TracChangeset for help on using the changeset viewer.