Time zones

Working with Dates and Times in R

Charlotte Wickham

Instructor

Time zones

Sys.timezone()
"America/Los_Angeles"
Working with Dates and Times in R

IANA Timezones

OlsonNames()
"Africa/Abidjan"         "Africa/Accra"                    
"Africa/Addis_Ababa"     "Africa/Algiers"                  
"Africa/Asmara"          "Africa/Asmera"                   
"Africa/Bamako"          "Africa/Bangui"
...
length(OlsonNames())
594
Working with Dates and Times in R

Setting and extracting

mar_11 <- ymd_hms("2017-03-11 12:00:00", 
+     tz = "America/Los_Angeles")
mar_11
"2017-03-11 12:00:00 PST"
tz(mar_11)
"America/Los_Angeles"
Working with Dates and Times in R

Manipulating timezones

force_tz() - change the timezone without changing the clock time

mar_11
"2017-03-11 12:00:00 PST"
force_tz(mar_11, 
    tzone = "America/New_York")
"2017-03-11 12:00:00 EST"

with_tz() - view the same instant in a different timezone

mar_11
"2017-03-11 12:00:00 PST"
with_tz(mar_11, 
    tzone = "America/New_York")
"2017-03-11 15:00:00 EST"
Working with Dates and Times in R

Let's practice!

Working with Dates and Times in R

Preparing Video For Download...