How relative-human readable time works for Date Time field in JIRA
Problem
When you use Date fields JIRA like Created, Updated or any other custom field type of Date Time Picker you can see that actual date is replaces with which is also called relative dates like: Just now, x minute ago, x days ago and 1 week ago.
It may be confusing how this human readable date is calculated, so we give some examples:
- Up to 50 minutes it will calculate minutes
- From 50 to 90 minutes it will tell 1 hour ago
- Within the same day and up to 1 day it will tell x hours ago
- For date from yesterday it will tell Yesterday
- Up to 8 days it will tell x days ago (but min - 2 days)
Some specifics about x days ago. It will be calculated from current time not from start of day and rounded down to full number of days.
A couple of examples: let's assume that Today is 2015-08-18 12:00
- At 2015-08-17 11:00 - Yesterday
- At 2015-08-16 18:00 - 2 days
- At 2015-08-16 11:00 - 2 days
- At 2015-08-15 18:00 - 2 days
- At 2015-08-15 11:00 - 3 days
- At 2015-08-14 18:00 - 3 days
- At 2015-08-14 11:00 - 4 days
Details:
Date modification is done n JavaScript, It will parse any 'livestampdata' DOM object. This is the snipet of the code which doing days calculations:
;/* module-key = 'jira.webresources:jquery-livestamp', location = '/includes/jquery/plugins/livestamp/time.js' */
..
case "xDaysAgo":
return AJS.format("{0} days ago", param);
} else {
if (date > now.clone().subtract("d", 7)) {
return getTextForRelativeAge("xDaysAgo", type, Math.max(getDaysBetween(date, now), 2))
} else {
And function getDaysBetween looks like:
function getDaysBetween(start, end) {
return Math.floor(end.diff(start, "days", true))
}
Disabling Relative Dates
It may makes sense for some systems to disable relative dates and display standard date formats. This can be done as mentioned here: Display standard dates in Jira server