Is it possible to achieve this?
1-Using human_time_diff only for post date less than 4 days.
For post 4 days and older just show basic date, eg: October 18, 2018
2-get the actual day, date and time in title attribute (see attachement).
When user hover the date, this date show up
This what i have right now:
<span class=”td-post-date” title=”how to get actual date here?”><?php echo human_time_diff( get_the_time(‘U’), current_time(‘timestamp’) ) . ‘ ago’; ?></span>
manage to get the title attribute with this:
<span class="td-post-date" title="<?php echo get_post_time( 'l, j F Y, g:i A', false, null, true );?>"><?php echo human_time_diff( get_the_time('U'), current_time('timestamp') ) . ' ago'; ?></span>
is that correct? now only need human_time_diff for post less than 4 days
Hi,
It’s possible with the cloud post templates for post templates. The date can be displayed in a time ago format (for 7 days)
You can test this by previewing then editing a post template here
– https://affiliate.tagdiv.com/#/load/Single
– https://www.screencast.com/t/5jK9ApgeYCN
For default post templates you could try with code like you mention and modify the template files. Check some online topics with ways to set a days limit
– http://wpcrux.com/blog/wordpress-date-time-ago/
– https://www.sitepoint.com/counting-the-ago-time-how-to-keep-publish-dates-fresh/
Also some forum topics – https://forum.tagdiv.com/topic/the-time-ago-in-block-3-is-correct-but-another-block-is-wrong-time/
Thanks
Hi Simion,
Thanks for the feedback. Really helpful. Just one more thing, can you show me example how to implement this code inside module files?
– http://wpcrux.com/blog/wordpress-date-time-ago/
Thanks