WordPress.org

Ready to get started?Download WordPress

Forums

Latest Tweets Widget
[resolved] Twitter time instead of date? (4 posts)

  1. wpnewbie69
    Member
    Posted 11 months ago #

    Is it possible to have the date say "3 days ago, 1 hour ago, etc." instead of the date?

    https://wordpress.org/plugins/latest-tweets-widget/

  2. timwhitlock
    Member
    Plugin Author

    Posted 11 months ago #

    Use the latest_tweets_render_date filter to perform your own relative date representation.

    https://wordpress.org/plugins/latest-tweets-widget/other_notes/#Theming

  3. wpnewbie69
    Member
    Posted 11 months ago #

    Just in case anyone else wants to display the time in this format:

    add_filter('latest_tweets_render_date', function( $created_at ){
        $date = DateTime::createFromFormat('D M d H:i:s O Y', $created_at );
        return sprintf( '%s ' . __( 'ago' ), human_time_diff( $date->format('U') ) );
    });
  4. timwhitlock
    Member
    Plugin Author

    Posted 11 months ago #

    Nice one. I didn't know about the human_time_diff function in WordPress.

Reply

You must log in to post.

About this Plugin

About this Topic

Tags

No tags yet.