Learn R Programming

countytimezones (version 1.0.0)

calc_single_datetime: Convert UTC to local time for a single observation

Description

This function calculated the local date-time for an observation based on a date-time in Coordinated Universal Time (UTC). The function provides a wrapper for the with_tz function form the lubridate package. It converts output from the with_tz function to a character vector so other functions in this package can be applied without error to with a dataframe with observations from multiple time zones to local time.

Usage

calc_single_datetime(datetime, tz)

Arguments

datetime
A POSIXct object of length one expressed in Coordinated Universal Time (UTC)
tz
A character string giving the local time zone based on the Olson/IANA time zone names

Value

A character string giving the date-time in the local time zone

Examples

Run this code
utc_time <- as.POSIXct("1999-09-15 14:30:00", tz = "UTC")
local_time <- calc_single_datetime(utc_time, tz = "US/Eastern")

Run the code above in your browser using DataLab