Exercise

Viewing in a timezone

To view a datetime in another timezone use with_tz(). The syntax of with_tz() is the same as force_tz(), passing a datetime and set the tzone argument to the desired timezone. Unlike force_tz(), with_tz() isn't changing the underlying moment of time, just how it is displayed.

For example, the difference between now() displayed in the "America/Los_Angeles" timezone and "Pacific/Auckland" timezone is 0:

now <- now()
with_tz(now, "America/Los_Angeles") - 
  with_tz(now,  "Pacific/Auckland")

Help me figure out when to tune into the games from the previous exercise.

Instructions

100 XP
  • Most fans will tune in from New Zealand. Use with_tz() to display game2_local in New Zealand time. New Zealand is in the "Pacific/Auckland" timezone.
  • I'll be in Corvallis, Oregon. Use with_tz() to display game2_local my time. Corvallis is in the "America/Los_Angeles" timezone.
  • Finally, use with_tz() to display game3_local in New Zealand time.