toUTC: Convert POSIXt Object to UTC Time Zone

Description Usage Arguments Value Examples

View source: R/convert.R

Description

Convert POSIXt Object to UTC Time Zone

Usage

1
toUTC(x)

Arguments

x

object of class POSIXt (either POSIXct or POSIXlt)

Value

POSIXt object in UTC timezone (hopefully!)

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
# Create a timestamp in the time zone that is set on the local machine
time <- as.POSIXct("2017-11-01 01:16")

# Convert time zone to UTC
time_utc <- toUTC(time)

# The new time zone "UTC" is set in the attribute "tz"
attr(time_utc, "tz")

# The times mean the same, just expressed in another time zone!
time_utc == time

KWB-R/kwb.datetime documentation built on July 9, 2021, 10:28 p.m.