There is a function for that: human_time_diff()
. Use it like so: (U
because we want the unix timestamp)
<?php echo human_time_diff( get_the_time('U') ); ?>
If you want additional text, you can use the following
<?php printf (esc_html__('%s ago', 'yourlanguageslug'), human_time_diff(get_the_time('U'))); ?>
Related Posts:
- Can I use the same nonce for multiple requests on the same page?
- WordPress and magic quotes
- How to check if a string is a valid URL
- Pass media upload value to input field
- What does the token %1$s in WordPress represent [closed]
- WordPress redirect to landing page if not logged in
- PHP/Manual use of images? – 2 Questions
- Debugging upload problem: What part of WP does actual image-resizing?
- Remove class that has been added by parent theme
- Design view breaking on Pages
- I want to remove the links from the term list returned by get_the_term_list
- How to use a frontend URL with a Plugin
- Get list of shortcodes from content
- Adding Google Analytics code to the tag of specific pages
- query if on page/2/?
- Site Health : An active PHP session was detected
- How to display a value from a radio button in the options menu in wordpress
- How to debug php code in hostgator cPanel
- Put php variable in shortcode
- Custom image upload
- Create Logout Link WordPress Admin Menu
- How to link a Page with an anchor tag in WordPress
- Working with query_posts ( arrays and query strings)
- WordPress can’t echo brackets
- action is not called after a php request
- Add a variable in functions.php and call it in single.php
- Linking text within textarea of custom meta box
- Ajax random number always the same
- How do you get final outputed HTML in PHP?
- How to change the oembed “type”?
- Modify user profile data through scripting?
- wordpress + woocommerce display product with additional information [closed]
- Post repeating with infinite scroll
- running arbitrary php files
- WordPress Ajax Call inserting data but success response false
- Can’t print Yoast meta description into page template (syntax error, unexpected ‘.’) [closed]
- Loading php file with AJAX in WordPress frontend
- Theme’s Options Page included with require_once *.php in functions.php not visible anymore
- what do I replace get_bloginfo with and where do I find all instances of it?
- Using data sent via AJAX in multiple functions on a WP plugin
- WordPress archive page showing 404 Error [duplicate]
- Utilize Function in Child Theme / Template File
- how to display this functions?
- How to have different site identity logos on each page on Astra Theme [closed]
- is_page_template showing partial results
- WordPress loop by meta key that is an array? and how loop multiple arrays
- Order BY Most Liked And Published Between Previous Week Monday And Next Week Monday
- REST API works in browser and via AJAX but fails via cURL
- How to display different submenus?
- How to tag the main tag? [closed]
- Overide Variable in Child Theme
- WooCommerce: Display product categories to make IF statement
- Unable to access WordPress functions from functions.php
- Randomize Color Scheme Selection in Theme
- Why can’t I add a custom image in my navigation?
- Wp_editor doesn’t send the required data
- Calling a plugin from a page template in TwentyEleven
- AJAX function not working [closed]
- Can ‘Custom Field’ data be inserted into this Short Code?
- Hi need update in my terms for other taxonomy
- Free search and custom taxonomy query not providing the same result
- Merge 2 product attribute terms
- WordPress api post image raw data without being blank in media library
- display condition based on post term and status
- Not able to remove caption shortcode from the content
- Display WordPress archive template page in 3 columns and not 1 column [closed]
- Only the first image uploads
- Run do_shortcode on php template using JS function
- global $product is empty string when passed into function
- How to update custom fields when post is published?
- How to get all post status
- removing the standard dashboard widgets in WP so I Can replace with custom
- Shortcodes not processing inside post content
- Gravity Forms: How to add PHP function to confirmation conditional shortcode?
- wpdb->query returns different value to phpMyAdmin
- Change header on one page in WordPress
- get_filtered_term_product_counts – Get product terms if any products
- The link you followed has expired. Please try again
- How to Protect a private folder inside uploads folder, if User is not Logged In?
- Cleaner ‘for each’ loop for registering scripts in functions.php
- Premature end of script headers: wp-mail.php?
- When to use wp_register_script() function?
- setcookie() issues on running with HTTPS on WordPress
- New database entry to trigger runing PHP/SQL query through link with token, without logging into the website
- loading a php file to a specific page id
- defined (‘ABSPATH’) false after AJAX post to other PHP-file
- Getting error in sql query
- How limit the width of a fixed menu-bar on scroll?
- How can I enqueue comment-reply script only on certain page?
- Count posts per post-type for last month/week
- Posts with Custom Fields does not appear
- Use jQuery and AJAX to get HTML
- Conditional in foreach loop is outputting content twice
- Replace TinyMCE with Custom Built Editor
- Particular meta tag – viewport – insertion when dealing with plugin
- php grabbing every post made?
- Edit Error Page style
- How to sort wordpress posts by selecting a year from a drop down?
- PHP $_SESSION array – only showing current index
- How can I use AJAX in child theme template?