# built-in function for "today"
Sys.Date()
#> [1] "2019-11-11"
# Dates are actually just integers underneath
# we can coerce to integer to see that version of it
today_days <- as.integer(Sys.Date())
today_days
#> [1] 18211
# now if we try to turn that number back into a date, it breaks
as.POSIXct(today_days)
#> Error in as.POSIXct.numeric(today_days): 'origin' must be supplied
# we have to tell it what that number means
# by convention, it's days since the "Unix Epoch", which is Jan 1, 1970
# so we gotta remind it
as.POSIXct(today_days, origin = "1970-01-01")
#> [1] "1970-01-01 00:03:31 EST"
Created on 2019-11-11 by the reprex package (v0.3.0)