function k99_relative_time() {
$post_date = get_the_time('U');
$delta = time() - $post_date;
if ( $delta < 60 ) {
echo 'Less than a minute ago';
}
elseif ($delta > 60 && $delta < 120){
echo 'About a minute ago';
}
elseif ($delta > 120 && $delta < (60*60)){
echo strval(round(($delta/60),0)), ' minutes ago';
}
elseif ($delta > (60*60) && $delta < (120*60)){
echo 'About an hour ago';
}
elseif ($delta > (120*60) && $delta < (24*60*60)){
echo strval(round(($delta/3600),0)), ' hours ago';
}
else {
echo the_time('j\<\s\u\p\>S\<\/\s\u\p\> M y g:i a');
}
}
then put k99_relative_time()
; in theme file where you want this to appear.
Related Posts:
- Change HTML Produced by wp_list_comments()
- Modify human_time_diff() to shorten “days” to “d” and “hours” to “h” etc
- wp_schedule_event will it run if timestamp has passed?
- Swatch Internet Time for article timestamps
- Integrating Human Time Difference and Traditional Timestamps?
- Why am I seeing ‘true’ next to these timestamps?
- Auto update date time 1 times per day?
- What function changes a post’s timestamp?
- the_modified_time showing wrong date
- current_time(‘timestamp’) is wrong
- How to change post date only 1 time a day?
- How to get current timestamp in string format in Java? “yyyy.MM.dd.HH.mm.ss”
- Is there a “git touch” so I can push the same file with a new timestamp?
- NOW() function in PHP
- Get Unix timestamp with C++
- timestamp of time(0) at multiple places in a C++ program
- Convert datetime to Unix timestamp and convert it back in python
- How to convert SQL Server’s timestamp column to datetime format
- Should I use the datetime or timestamp data type in MySQL?
- How to get correct timestamp in C#
- Convert timestamp to date in Oracle SQL
- Sqlite: CURRENT_TIMESTAMP is in GMT, not the timezone of the machine
- How to make debug.log timestamps local time?
- Why time functions show invalid time zone when using ‘c’ time format?
- Converting Unix timestamp to wordpress date
- Date, Time, and Timezones
- Add 20yrs to post date, and then query
- Is it safe to use ‘date_default_timezone_set’ in plugin file?
- datetime picker, timestamps and meta queries
- Human Time Diff, change mins to minutes
- custom field value date convert to unix timestamp problems
- How to get time difference between publish date and now?
- Register script/style: Is it possible to customize the version query string via plugin?
- Query by custom dates in UNIX Time
- filter date and time to differents time zone
- WP Cron job every 1st and 15th of the month
- Relative time – how to calculate difference beween post publish date and current time
- possibility to control embedded video timeline with buttons and links external to the player
- WordPress outputs mm/dd but it should be opposite
- How to use Internationalized human_time_diff() function in Chinese?
- Save metadata as a timestamp, display as a “pretty” date
- wordpress convert timestamp to date not correctly
- Customize Time Stamp
- display month in french in wordpress/php?
- About Time conditionals
- How to add a new meta key and assign timestamp to posts
- How to find time last viewed?
- Update all comments time to random dates?
- Trouble Formatting DateTime
- Placed on + only date (not time)
- current_time(‘timestamp’) seems to be different from the real current time
- How can i display time minus 6 hours
- How to allow registered users to submit the form only 5 times per day?
- Time & Date on Post – Time Ago Custom Function
- How get exact time difference
- Update File Once Every 30 Days
- Where does the time get pulled from in the_time()
- Human time difference in months instead of days. How?
- How to get User Time Zone in WordPress?
- Query not work for current taxonomy
- How to show different timestamp
- Remove Page Timestamp via functions.php so it doesn’t show in Google Search Result Description [closed]
- admin end post published time display not working correctly
- Getting post by specific date in Advance Custom Field
- How to get movies by date
- how to compare different timestamps in wp-query for events custom post types?
- Display upcoming events in the next 30 days by querying posts with timestamp in custom meta
- create timestamp links to jump to specific times on rumble videos
- set_object_terms action hook based on the function in the published CPT
- current_time function incorrect in plugin and PHP, not in WordPress admin
- Measure time in ONLY HOUR format
- Deleting guests profile users after 1.5 hours
- Learndash: Customize user enroll time
- Cron task with scheduled timestamp in the past
- Change pubDate in rss feed in another format
- strtotime not working
- Count time from registration date to today
- Update existing post times to random times?
- Can’t add to time? [closed]
- Timezone for Plugin
- How to get Unix Local Time?
- datetime picker, timestamps and meta queries
- How to add a timestamp to the exported WXR filename?
- Calculate how much time passed comparing WordPress comment and current time
- WP_Query with UNIX timestamp in meta query
- How to display time when page is created and edited
- Selecting posts older than the current Unix epoch timestamp
- Convert all dates in field to Unix time, except those already in Unix time
- How to second orderby in “pre_get_posts” by meta value or combine single date and time to timestamp
- Time sort with meta_key using UNIX timestamp failing due to date differences
- If I change the taxonomy of a post will it get a new time stamp?
- Get system timestamp in wordpress
- How do I output user_registered time in my correct timezone?
- Custom time field won’t sort regardless of format
- Show monthly or daily archives
- one time visit to the page
- Datetime on time tag wordpress puts it outside the tag
- Date is showing in unreadable format. How to convert to readable date?
- Why does wp_query only display the most recent post when using order ASC?
- WP_Query filter Posts by timestamp event (range start and end) and by month (next 12 month)