I am confused with the output of the ymd_hms()
of the lubridate package
.
I scraped some data frome the web containing a time stamp of the following format:
time_series <- c("2019-10-17 23:43:50+00:00", "2019-10-17 23:43:50+01:00")
If I use ymd_hms()
on time series I get the following:
library(ludridate)
ymd_hms(time_series)
# [1] "2019-10-17 23:43:50 UTC" "2019-10-17 22:43:50 UTC"
Why is the second time stamp converted one hour earlier? From my understanding and also on the website where I scraped the data it should be one hour later (+01:00):
#[1] "2019-10-17 23:43:50 UTC" "2019-10-18 00:43:50 UTC"
What do I get wrong? And how do I change the behavior of ymd_hms() to get the desired output?
Even though this is an old question. Piotr K is absolutely right. Time is always communicated in relation to coordinated universal time (UTC). So the time stamp hh:mm:ss+01:00
means UTC + 1hour. As ymd_hms()
converts all timestamps to UTC by default the above behavior is absolutely correct.