What is the difference between Day and Date?

When auto-completing new Date() in the JourneyApps editor I noticed I have an option for new Day(). I have no idea what/why the options exist so my question is as follows:

Is there a fundamental difference between the Date and Day objects? If so, please explain what the difference is, and if possible provide any tips as to why I would use one method vs. the other.

There is a difference between these two, please see the "what" and "why":

What:

The Date object is the standard JavaScript date which contains the date, time and timezone.

The Day object represents only the Gregorian day, with no time or timezone.

Why:

The Day object is useful when you are not interested in the time component. For example, if you want to interface this data with another system which is only expecting the date component. In general, I would recommend using the standard Date component, unless you specifically only need the date.

3 Likes

The Day object is intended to avoid timezone problems when referring to a date (as in the whole day) and not a specific point in time. eg. a particular day would be stored as "2019-01-01T00:00:00Z" intending to mean 2019-01-01 anywhere in the world. However, for a user in a negative timezone (eg. UTC-6) that Date would be 2018-12-31T18:00:00-0600, which would be interpreted and displayed as 2018-12-31.

4 Likes