Relative dates - disparity in what is 'x days ago'


(Lisa) #1

Hi,

I’m noticing a difference between what’s displayed using the relative updated and published keywords on one of our pages.

Using the %globals_asset_updated_relative% and %globals_asset_published_relative% keywords it shows the updated date as ‘3 days ago’ and the published date as ‘4 days ago’, even though the page was both updated and published on the same day.

Is that because the relative keyword is comparing to the current time of about 1pm and the page was last updated at 3pm and last published at 11am? (Yes, it was updated after being published - but let’s not get hung up on that!)
I would expect that when the relative time is being measured in days it should compare to midnight rather than the current time. So if it was currently Monday and the page was updated on a Friday the relative keyword would display ‘3 days ago’ no matter what time on the actual day it was updated.

Cheers,
Lisa

Matrix Version: 5.3.4.2


(Bart Banda) #2

Just did some tests, and it looks like it’s based off the current time. Which I guess makes sense if you are looking at something at 2am, and the update happened at 11pm, you’d rather see 3 hours ago rather than 1 day ago.

I think it’s basically just using what PHP is using for relative date calculation: http://php.net/manual/en/datetime.formats.relative.php


(Lisa) #3

It makes sense to use the current time when the difference is being measured in seconds, minutes or hours. But comparing to the current hour when the changes were more than a day ago displays unexpected results - like in the example I gave where it’s saying something was updated 3 days ago and published 4 days ago, when it was updated and published on the same day.

That PHP relative date manual page you mentioned describes how dates can be initialised/created, but not how they are output. There must be some custom scripts running in Matrix for that ‘relative’ keyword modifier, and it seems like the logic is a little hinky…


(David Schoen) #4

Matrix is calculating the dates internally and basing it purely on the current time.

Whether or not that makes sense probably depends on what you’re used to, all the products I can think of that have relative times do it the same way as Matrix (i.e not rounding off to midnight when displaying days).

Rounding off relative times to the relevant unit might make sense as a feature for site owners that prefer it done that way but I’m not sure if it’d make sense as instance configuration (global to all of the Matrix install), something design level or even a keyword modifier.