Check out human_time_diff()
:
if ( DAY_IN_SECONDS < ( $time = current_time( 'timestamp' ) ) - ( $time_post = get_the_time( 'U' ) ) )
echo human_time_diff( $time_post, $time ) . ' ago';
else
the_time( 'F j, Y at g:i a' );
DAY_IN_SECONDS
is a handy “helper” constant in WordPress, along with:
MINUTE_IN_SECONDS
HOUR_IN_SECONDS
WEEK_IN_SECONDS
YEAR_IN_SECONDS
Related Posts:
- Unable to select an old date in wordpress
- How to get date for each post?
- Converting Unix timestamp to wordpress date
- Modify Date Format to German
- Serve visitor post time adjusted to their timezone
- Styling the date format with date_i18n
- Date and time format for UK in a custom post type [closed]
- What are the “U” and “G” time formats?
- date() returns incorrect value if used from WordPress theme, but correct otherwise
- How to get date using timezone saved in options? [duplicate]
- Set the publication date independent of the scheduled publication date
- Format Date for Manual Insertion into post
- Translate current_time
- Display published time for today’s posts only
- convert time to WordPress user’s local time
- Can’t convert ACF datepicker value to DateTime oject – gives me a boolean
- Count time from registration date to today
- Update existing post times to random times?
- Timezone for Plugin
- How to get Unix Local Time?
- How to display Date and Time in Tamil Language?
- Get current week’s day and time outside the loop
- Use the_date with link
- automatic send email at custom time
- Change the date and time in wordpress
- How to second orderby in “pre_get_posts” by meta value or combine single date and time to timestamp
- Advanced Custom Fields and date picker, show posts only if the day is today no matter the year
- Get system timestamp in wordpress
- How to customize Date Format for American visitors?
- Java SimpleDateFormat for YYYY-MM-DDThh:mm:ssTZD
- How do I use PHP to get the current year?
- The purpose of the post_date_gmt?
- How to integrate get_post_time with date_i18n function?
- Get date of last update outside of loop
- WordPress Custom Query to show posts from last x years
- How to show the real post date in a draft
- How to remove published date from RSS feed
- XML export posts from one single day
- Bulk edit post date in wordpress
- WordPress returns a wrong date
- Date query not inclusive despite parameter being true
- WordPress post dating – pre 1901?
- Unable to set right time in admin and frontend template
- the_modified_date returns published date
- Page Revision date displaying on google search
- Display post date as 04/26/2013
- Calculate future date
- Advanced custom fields: Customise date picker’s start date (need to choose year 1500 onwards) [closed]
- wordpress convert timestamp to date not correctly
- Show post updated date instead of published
- Add a link to display posts with a specific tag within a date range
- About Time conditionals
- If modified on same day, show only time
- Mini app that shows one unique quote each day. 56 rotating posts rotating for each themed weekday. It works, but I need your advice
- Print last modified date only on posts
- Make WordPress use timezone for email Date header
- Escaping date string in url with wordpress
- Is there anything special I have to think of when setting post_date_gmt when inserting a new post?
- Copyright: Get first and last date of post type
- Wrong date returned by get_the_time
- Get_the_date doesnt show todays date [closed]
- Are there any know limitations on the date field, especially how old dates can be?
- Return date in French
- Changing default WP-Site creation date
- Bulk Updating Post Date in 1 day Increments
- How to get User Time Zone in WordPress?
- Display Author Registration Date
- How display modified date of most recent modified post in wordpress?
- Date Language doesn’t change
- display future posts in date page
- Month display in English but required in Swedish?
- Update post date of page when Visitor access that page?
- Get date function not working
- Media attachment date and post date
- If Post Published Date or Modified Date is 1 Year or Older, Display Notice on Post Page
- Is it possible to change X Hours Ago to date in WP Admin?
- Check if is Post or Comment
- changing type of date picker in contact form 7 date picker plugin
- User set date and time from frontend doesn’t get stored into database
- Get current user last post date
- I want to format my Post dates differently to other dates on my website
- How to display posts categori list by day wordpres
- How to add published date in product [closed]
- Tumblr imported blog showing wrong date
- Can’t add to time? [closed]
- How to hide post published date?
- Adding a number to a date
- Notify after 3,6,9 and then 12 months after plugin activation
- suffix title with “EXPIRED” when scheduled post has reached it’s published date
- Show post date on the page
- Set Custom Date for Posts
- Posted date format not reflected
- check if a draft has been moved there from publish to draft
- Saving Revision of post meta key/value on each update_post_meta event
- Comment time is same as the post time
- wp_date doesn’t work
- How to get the date of all blog posts
- In my Website homepage I want to remove date which is written along author name [closed]
- get_the_date() return always UTC+0 [duplicate]
- Convert custom field date format to “WordPress default”