Introduction
We currently store all dates entered into the platform as SQL datetime fields as UTC. This allows use to be able to display dates back to the user using timezones, etc.
Over the last year (or more) have received numerous questions around how we use timezones to display the dates for various modules.
We use three types of dates across the platform:
-
UTC = Universal Time, timezone info can then be applied to the UTC date and time for display purposes.
-
Example:
2021-01-01T00:00:000
When viewing this in Florida, USA it will be displayed as 31st December 2020, 17:00.
-
-
Relative date = a human readable version of a date, normally relative to the current date and time.
-
Example:
2021-01-01T00:00:000
When viewing this in relative date time it will be displayed as about a month ago when viewing it on 1st of February 2021.
-
-
Absolute date = a formatted version of a date, normally to display the values in year, month, day, and time, the order of these can vary. The display will generally remain the same, regardless of when it’s viewed.
-
Example:
2021-01-01T13:45:123
When viewing this in absolute date time it could be displayed as Fri, 1 Jan 2021, 13:45.
-
Absolute Time
Absolute time is where a date is display (and often formatted) as it’s been stored when added to a database. These are generally used to help the user understand when something was created, or when something might occur at a specific date and time. Good use-cases for absolute time is documents, tasks or requests. When displaying dates in Absolute time, there are a few considerations to take into account:
-
Is it important to include the time?
-
Does the date need to be displayed according to the user’s timezone?
Relative Time
As mentioned before, relative time displays a date in a more human readable way, and can help users more easily stay up to date with information as it happens. Good use-cases for this is article published dates, dates comments where made. The date is more than likely to occur in the past, and it is not important for the user to understand exactly when. A user can read a relative date and quickly interpret it in context to the current day. It is also recommended to give the user the option to view the actual date via a tooltip (this could be a built-in Browser tooltip, or a UI component tooltip).
Date and Time Timezone
This is where things start to get complicated. If User X creates a Task for User Y, and User X is sitting in their living room in London, and User Y is working from their home office in Florida. User X sets a due date for the Task to be the 2nd of March 2021, with a time of 12:00 (mid-day). This will be stored in the database dueDateTime field as 2021-03-02T12:00:000. The questions here are:
-
User X would expect the Task to be completed by 12:00 on the 2nd of March 2021.
-
User Y would see the Task’s due date and time as Tue, 2 Mar 2021, 07:00.