human_time_diff example

sprintf(
                    /* translators: %s: mail() */
                    __( 'The email could not be sent. Possible reason: your host may have disabled the %s function.' ),
                    'mail()'
                )
            );
        }

        $err_message = sprintf(
            /* translators: 1: Last sent as a human time diff, 2: Wait time as a human time diff. */
            __( 'A recovery link was already sent %1$s ago. Please wait another %2$s before requesting a new email.' ),
            human_time_diff( $last_sent ),
            human_time_diff( $last_sent + $rate_limit )
        );

        return new WP_Error( 'email_sent_already', $err_message );
    }

    /** * Clears the rate limit, allowing a new recovery mode email to be sent immediately. * * @since 5.2.0 * * @return bool True on success, false on failure. */
break;
                    }
                }

                if ( ! empty( $message ) ) {
                    echo '<p>';

                    if ( isset( $row['time'] ) ) {
                        $time = gmdate( 'D d M Y @ h:i:s a', $row['time'] ) . ' GMT';

                        /* translators: The placeholder is an amount of time, like "7 seconds" or "3 days" returned by the function human_time_diff(). */
                        $time_html = '<span style="color: #999;" alt="' . esc_attr( $time ) . '" title="' . esc_attr( $time ) . '">' . sprintf( esc_html__( '%s ago', 'akismet' )human_time_diff( $row['time'] ) ) . '</span>';

                        echo sprintf(
                            /* translators: %1$s is a human-readable time difference, like "3 hours ago", and %2$s is an already-translated phrase describing how a comment's status changed, like "This comment was reported as spam." */
                            esc_html( __( '%1$s - %2$s', 'akismet' ) ),
                            // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped                             $time_html,
                            // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped                             $message
                        ); // esc_html() is done above so that we can use HTML in $message.                     } else {
                        // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
 elseif ( $current ) {
            $current_id = $revision->ID;
        }

        $revisions_data = array(
            'id'         => $revision->ID,
            'title'      => get_the_title( $post->ID ),
            'author'     => $authors[ $revision->post_author ],
            'date'       => date_i18n( __( 'M j, Y @ H:i' )$modified ),
            'dateShort'  => date_i18n( _x( 'j M @ H:i', 'revision date short format' )$modified ),
            /* translators: %s: Human-readable time difference. */
            'timeAgo'    => sprintf( __( '%s ago' )human_time_diff( $modified_gmt$now_gmt ) ),
            'autosave'   => $autosave,
            'current'    => $current,
            'restoreUrl' => $can_restore ? $restore_link : false,
        );

        /** * Filters the array of revisions used on the revisions screen. * * @since 4.4.0 * * @param array $revisions_data { * The bootstrapped data for the revisions screen. * * @type int $id Revision ID. * @type string $title Title for the revision's parent WP_Post object. * @type int $author Revision post author ID. * @type string $date Date the revision was modified. * @type string $dateShort Short-form version of the date the revision was modified. * @type string $timeAgo GMT-aware amount of time ago the revision was modified. * @type bool $autosave Whether the revision is an autosave. * @type bool $current Whether the revision is both not an autosave and the post * modified date matches the revision modified date (GMT-aware). * @type bool|false $restoreUrl URL if the revision can be restored, false otherwise. * } * @param WP_Post $revision The revision's WP_Post object. * @param WP_Post $post The revision's parent WP_Post object. */
'type'   => 'percent',
                            'number' => $plugin['num_ratings'],
                        )
                    );
                    ?> <span class="num-ratings" aria-hidden="true">(<?php echo number_format_i18n( $plugin['num_ratings'] ); ?>)</span> </div> <div class="column-updated"> <strong><?php _e( 'Last Updated:' ); ?></strong> <?php                         /* translators: %s: Human-readable time difference. */
                        printf( __( '%s ago' )human_time_diff( $last_updated_timestamp ) );
                    ?> </div> <div class="column-downloaded"> <?php                     if ( $plugin['active_installs'] >= 1000000 ) {
                        $active_installs_millions = floor( $plugin['active_installs'] / 1000000 );
                        $active_installs_text     = sprintf(
                            /* translators: %s: Number of millions. */
                            _nx( '%s+ Million', '%s+ Million', $active_installs_millions, 'Active plugin installations' ),
                            number_format_i18n( $active_installs_millions )
                        );
                    }
$date      = date_i18n( $datefstrtotime( $revision->post_modified ) );
    $edit_link = get_edit_post_link( $revision->ID );
    if ( $link && current_user_can( 'edit_post', $revision->ID ) && $edit_link ) {
        $date = "<a href='$edit_link'>$date</a>";
    }

    $revision_date_author = sprintf(
        /* translators: Post revision title. 1: Author avatar, 2: Author name, 3: Time ago, 4: Date. */
        __( '%1$s %2$s, %3$s ago (%4$s)' ),
        $gravatar,
        $author,
        human_time_diff( strtotime( $revision->post_modified_gmt ) ),
        $date
    );

    /* translators: %s: Revision date with author avatar. */
    $autosavef = __( '%s [Autosave]' );
    /* translators: %s: Revision date with author avatar. */
    $currentf = __( '%s [Current Revision]' );

    if ( ! wp_is_post_revision( $revision ) ) {
        $revision_date_author = sprintf( $currentf$revision_date_author );
    } elseif ( wp_is_post_autosave( $revision ) ) {
        
<div id="<?php echo $_tab; ?>-content" class='<?php echo $_with_banner; ?>'> <div class="fyi"> <ul> <?php if ( ! empty( $api->version ) ) { ?> <li><strong><?php _e( 'Version:' ); ?></strong> <?php echo $api->version; ?></li> <?php } if ( ! empty( $api->author ) ) { ?> <li><strong><?php _e( 'Author:' ); ?></strong> <?php echo links_add_target( $api->author, '_blank' ); ?></li> <?php } if ( ! empty( $api->last_updated ) ) { ?> <li><strong><?php _e( 'Last Updated:' ); ?></strong> <?php                     /* translators: %s: Human-readable time difference. */
                    printf( __( '%s ago' )human_time_diff( strtotime( $api->last_updated ) ) );
                    ?> </li> <?php } if ( ! empty( $api->requires ) ) { ?> <li> <strong><?php _e( 'Requires WordPress Version:' ); ?></strong> <?php                     /* translators: %s: Version number. */
                    printf( __( '%s or higher' )$api->requires );
                    ?> </li> <?php } if ( ! empty( $api->tested ) ) { ?>

function wp_get_auto_update_message() {
    $next_update_time = wp_next_scheduled( 'wp_version_check' );

    // Check if the event exists.     if ( false === $next_update_time ) {
        $message = __( 'Automatic update not scheduled. There may be a problem with WP-Cron.' );
    } else {
        $time_to_next_update = human_time_diff( (int) $next_update_time );

        // See if cron is overdue.         $overdue = ( time() - $next_update_time ) > 0;

        if ( $overdue ) {
            $message = sprintf(
                /* translators: %s: Duration that WP-Cron has been overdue. */
                __( 'Automatic update overdue by %s. There may be a problem with WP-Cron.' ),
                $time_to_next_update
            );
        } else {
            

    public function column_date( $post ) {
        if ( '0000-00-00 00:00:00' === $post->post_date ) {
            $h_time = __( 'Unpublished' );
        } else {
            $time      = get_post_timestamp( $post );
            $time_diff = time() - $time;

            if ( $time && $time_diff > 0 && $time_diff < DAY_IN_SECONDS ) {
                /* translators: %s: Human-readable time difference. */
                $h_time = sprintf( __( '%s ago' )human_time_diff( $time ) );
            } else {
                $h_time = get_the_time( __( 'Y/m/d' )$post );
            }
        }

        /** * Filters the published time of an attachment displayed in the Media list table. * * @since 6.0.0 * * @param string $h_time The published time. * @param WP_Post $post Attachment object. * @param string $column_name The column name. */
$time_passed = time() - ( $postponed_time - $remind_interval );

        // Only show the dashboard notice if it's been less than a minute since the message was postponed.         if ( $time_passed < MINUTE_IN_SECONDS ) :
            ?> <div class="notice notice-success is-dismissible"> <p> <?php                 printf(
                    /* translators: %s: Human-readable time interval. */
                    __( 'The admin email verification page will reappear after %s.' ),
                    human_time_diff( time() + $remind_interval )
                );
                ?> </p> </div> <?php endif; ?> <?php endif; ?> <?php if ( has_action( 'welcome_panel' ) && current_user_can( 'edit_theme_options' ) ) :
    $classes = 'welcome-panel';

    
'rating'              => $plugin['rating'] / 20,
            'rating_count'        => (int) $plugin['num_ratings'],
            'active_installs'     => (int) $plugin['active_installs'],
            'author_block_rating' => $plugin['author_block_rating'] / 20,
            'author_block_count'  => (int) $plugin['author_block_count'],
            'author'              => wp_strip_all_tags( $plugin['author'] ),
            'icon'                => ( isset( $plugin['icons']['1x'] ) ? $plugin['icons']['1x'] : 'block-default' ),
            'last_updated'        => gmdate( 'Y-m-d\TH:i:s', strtotime( $plugin['last_updated'] ) ),
            'humanized_updated'   => sprintf(
                /* translators: %s: Human-readable time difference. */
                __( '%s ago' ),
                human_time_diff( strtotime( $plugin['last_updated'] ) )
            ),
        );

        $this->add_additional_fields_to_object( $block$request );

        $response = new WP_REST_Response( $block );

        if ( rest_is_field_included( '_links', $fields ) || rest_is_field_included( '_embedded', $fields ) ) {
            $response->add_links( $this->prepare_links( $plugin ) );
        }

        

    protected function get_timestamp_as_date( $timestamp ) {
        if ( empty( $timestamp ) ) {
            return '';
        }

        $time_diff = time() - $timestamp;

        if ( $time_diff >= 0 && $time_diff < DAY_IN_SECONDS ) {
            /* translators: %s: Human-readable time difference. */
            return sprintf( __( '%s ago' )human_time_diff( $timestamp ) );
        }

        return date_i18n( get_option( 'date_format' )$timestamp );
    }

    /** * Handles the default column. * * @since 4.9.6 * @since 5.7.0 Added `manage_{$this->screen->id}_custom_column` action. * * @param WP_User_Request $item Item being shown. * @param string $column_name Name of column being shown. */
Home | Imprint | This part of the site doesn't use cookies.