lubridate (version 1.3.0)

force_tz: Replace time zone to create new date-time

Description

force_tz returns a the date-time that has the same clock time as x in the new time zone. Although the new date-time has the same clock time (e.g. the same values in the year, month, days, etc. elements) it is a different moment of time than the input date-time. force_tz defaults to the Universal Coordinated time zone (UTC) when an unrecognized time zone is inputted. See Sys.timezone for more information on how R recognizes time zones.

Usage

force_tz(time, tzone = "")

Arguments

time
a POSIXct, POSIXlt, Date, or chron date-time object.
tzone
a character string containing the time zone to convert to. R must recognize the name contained in the string as a time zone on your system.

Value

  • a POSIXct object in the updated time zone

See Also

with_tz

Examples

Run this code
x <- as.POSIXct("2009-08-07 00:00:01", tz = "America/New_York")
force_tz(x, "GMT")
# "2009-08-07 00:00:01 GMT"

Run the code above in your browser using DataCamp Workspace