Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

local_time

Get local time from a date-time vector.


Description

local_time retrieves day clock time in specified time zones. Computation is vectorized over both dt and tz arguments, the shortest is recycled in accordance with standard R rules.

Usage

local_time(dt, tz = NULL, units = "secs")

Arguments

dt

a date-time object.

tz

a character vector of timezones for which to compute the local time.

units

passed directly to as.difftime().

Examples

x <- ymd_hms(c("2009-08-07 01:02:03", "2009-08-07 10:20:30"))
local_time(x, units = "secs")
local_time(x, units = "hours")
local_time(x, "Europe/Amsterdam")
local_time(x, "Europe/Amsterdam") == local_time(with_tz(x, "Europe/Amsterdam"))

x <- ymd_hms("2009-08-07 01:02:03")
local_time(x, c("America/New_York", "Europe/Amsterdam", "Asia/Shanghai"), unit = "hours")

lubridate

Make Dealing with Dates a Little Easier

v1.7.10
GPL (>= 2)
Authors
Vitalie Spinu [aut, cre], Garrett Grolemund [aut], Hadley Wickham [aut], Ian Lyttle [ctb], Imanuel Costigan [ctb], Jason Law [ctb], Doug Mitarotonda [ctb], Joseph Larmarange [ctb], Jonathan Boiser [ctb], Chel Hee Lee [ctb], Google Inc. [ctb, cph]
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.