WordPress has a core function human_time_diff
that does what you want, using it with the filter you provide you have someting like so:
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') ) );
});
Related Posts:
- Calculate business days
- the_date() not working
- Archive listing of posts by publish year (multiple years)
- Twitter feed is showing blank in WP site [closed]
- WordPress returns a wrong date
- Unable to set right time in admin and frontend template
- WP_Query meta_query results date by date
- Way to display “Yesterday”, “Today”
- display month in french in wordpress/php?
- Get date numerical and separate?
- Print last modified date only on posts
- Adding number to date not working [closed]
- Set meta field to publish date + 2 weeks
- How to manually change current date to post date in frontend?
- Convert WordPress date format to jQuery UI Datepicker format
- Converting Y-m-d to a date with a Month name? [closed]
- How to get User Time Zone in WordPress?
- Using php inside javascript [closed]
- Get date function not working
- Is there way to toggle the publish date display?
- If Post Published Date or Modified Date is 1 Year or Older, Display Notice on Post Page
- Issue in displaying the ongoing event and current events in the post
- WordPress wrong dates bug
- Don’t update modified post date when user add a product review or comment?
- Possible to edit custom date field and display?
- Get posts from year from URL
- Changing Date Format on Custom Meta Data w/shortcode call
- Primary navigation menu with timed items from custom post type
- Can’t add to time? [closed]
- Grouping posts by date
- WordPress change post date format from english to japanese
- Comparing Dates within plugin using PHP If statement
- Adding a number to a date
- Display Year and Month from custom field + Age Calculator
- Convert custom field date format to “WordPress default”
- How to set and use global variables? Or why not to use them at all
- What is in media-template.php, and how does it work?
- Create Image Uploader for Widget
- Displaying a variable stored in functions.php inside widget
- Passing a shortcode attribute to a sub-function
- Insert post without actions/hooks
- phpMyAdmin displays error when importing database
- Setting up 2 SMTP accounts: 1 for wordpress and 1 for woocommerce
- Displaying the last post on static homepage
- Using foreach loop breaks
- How to remove the cufon script from Dzonia Lite theme [closed]
- WordPress plugin for nicer looking slugs? Have multiple pages named the same but they get different slugs
- Showing a different gallery in a seperate post
- How to put “Read more” link in Custom Excerpt inside p tag?
- WordPress Shortcodes.. printf is outputting a random number… Can’t figure out WHY?
- Remove metabox from WordPress menu editor page?
- Ajax request returns ‘Array’. How to output the actual results?
- subdirectory index.php is not working
- My php header() function is not working [closed]
- Form Security: nonce vs. jQuery
- meaning of (array)function()
- Buddypress update user avatar image via REST
- Accessing $post after PHP is executed
- How to use the wpsnonce clone post link?
- change the default order of posts only for specific categories
- Array to string conversion error in PHP 7.2 when returning user role as class
- Problem with adding custom CSS class to image in ACF Photo Gallery plugin [closed]
- How can I get “Previous” and “Next” to show in the navigation besides the links?
- Link to page with posts of specific type
- Order a WP_Query by meta value where the value is an array
- How to use functions [closed]
- Splitting the_content() by size?
- with PHP within splits the link
- Conditionally load class in the comment section of the post page
- Saving a post ID to use in a form elsewhere on website
- Trying to change image funtion from enlarge image to redirect to amazon website
- Manually Remove and Change WordPress Page/Post Title
- Using theme options to change a border-radius value
- Add more user roles to a PHP logout redirect function [closed]
- can’t load .po file in functions.php
- Create shortcode for metabox gallery
- WooCommerce – template_redirect if is_checkout AND order has been paid?
- Display attached images of a page or post that are insetred using gallery
- overwrite wordpress gallery with custom gallery shortcode
- Upgrade to PHP7.3 and Changing Apache from Prefork to Event Breaks WordPress
- Hot to edit WooCOmmerce dashboard?
- Add wp posts to cutom masonry grid
- dynamically change content of div with php
- Custom WordPress Core upgrade through wp-cli
- add a value to an external link query in searchform
- ACF + WP + Slick Slider Repeater Slide Group PHP not Displaying [closed]
- Showing the project type in HREF
- INCOMING: Wall of code for form and $_POST, not updating custom field’s value
- Adding theme strings to .PO file
- How to exclude post from being queried based on custom meta value
- WordPress – show number of comments for each post in widget
- WP_Nav Highlight Parent Issue
- What is this mark for “? function()” [closed]
- Can php warnings cause an Internal Server Error?
- Set post to draft if matching word is found in the post
- Warning: filemtime(): stat failed for wp_
- How can I change the URL via add_rewrite_rule()
- Variable ++ in query loop
- Generate and upload screenshot as featured image for user-submitted post
- How can precision be improved for the debug log timestamp?