Introduction to date and time
In R, there are three objects related to date and time: date
, time
, and datetime
. The definition is as logical as it looks:
- date: Object refers to a date
YYYY-MM-DD
- time: Object stores time data, as
HH:
MM: SS
- datetime: A combination of both
YYYY-MM-DD HH:
MM: SS
From now on, I will mostly refer to datetime objects, as these are a combination of both other types and are the most common as well.
It is important to note that computers calculate time based on January 1, 1970, at 00:00:00 UTC. As a side note, UTC means Universal Time Coordinated, formerly known as Greenwich Mean Time (GMT), which is the point that regulates the world time zones. Every calculation of time zone is done from that point, adding or subtracting hours.
In the late 1960s and early 1970s, Unix engineers had to pick a date to use as ground zero when the clock started to count for computers. For the sake of calculation easiness, January 1 was convenient...