Getting the current date

Basic types / Date and time

# The current moment, in the session's time zone
now <- Sys.time()

# Date only
today <- Sys.Date()

# The same moment in other zones, by their names
utc_time <- format(now, tz = "UTC", usetz = TRUE)
london_time <- format(now, tz = "Europe/London",
                      usetz = TRUE)
pacific_time <- format(now, tz = "Pacific/Wake",
                       usetz = TRUE)

# cat() prints a raw number: use format()
cat("now =", format(now), "\n")
cat("today =", format(today), "\n")
cat("utc_time =", utc_time, "\n")
cat("london_time =", london_time, "\n")
cat("pacific_time =", pacific_time, "\n")