Hi all. Can you please tell me how to display time of publishing so that it rounds to closest single unit (hour, day, week, month or year).
Current time/date - Creation time/date = time rounded to closest single unit (hour, day, week, month or year)
here are several examples just to make sure we are on the same page: 1 day ago, 1 week ago, 2 weeks ago, month ago, 8 month ago, 3 years ago… something like this
When you say ‘etc’ do you mean I can also use this method for Artur’s other 3 examples of weeks, months, and years?
I’ve managed to do this for hours and days as per above but can’t work out your method for the other 3 time formats.
If you have time, can you also give an example of a conditional as well eg. if less than 1 day show ‘hours’ text if more than 2 weeks show ‘weeks’ text.
For others trying to find an answer, I have attached screenshots of Nigel’s suggestion for seconds/minutes/hours/days ago here.
However, you can’t use this really in production as you don’t want something to display ‘568 days ago’ as it would be more sensible as weeks or years.
The first screenshot shows the normal set up in hours and the second screenshot shows the different displays of minutes or days depending on how old the thing is.