The issues are:
– If the post date is older than 7 days, it must just have default behavior. So I just try to output the date, but this code doesn’t work. The page keeps loading and won’t load.
– If the post date is newer than 7 days, it must show the human_time_diff. It works, but the datetime attribute for the <time> element also shows the human_time_diff instead of the valid default behavior like “2020-06-04T03:04:00+02:00”
So I want this part to show default behavior as well, even though the post is less than 7 days old. The text for the reader must be human_time_diff only.
Any help to accomplish this (perhaps more elegantly) would be appreciated!
Here is the desired HTML result (examples): Post is less than 7 days old:
<time class=”entry-date published” datetime=”2020-06-04T03:04:00+02:00″>2 days ago</time>
Post is more than 7 days old:
<time class=”entry-date published” datetime=”2020-06-04T03:04:00+02:00″>June 4, 2020</time>