Skip to contents

Given a string of numbers, a conversion is done to the POSIXct date-time class. The string is assumed to be of the form YYYYMMDD, YYYYMMDDhh, YYYYMMDDhhmm, or YYYYMMDDhhmmss with time zone UTC.

Usage

as_dttm(x)

Arguments

x

A numeric character string or numeric object

Value

A date-time object of class POSIXct

Examples

# Character input
as_dttm("20220203")
#> [1] "2022-02-03 UTC"
as_dttm("2022020306")
#> [1] "2022-02-03 06:00:00 UTC"
as_dttm("202202030630")
#> [1] "2022-02-03 06:30:00 UTC"
as_dttm("20220203063022")
#> [1] "2022-02-03 06:30:22 UTC"
#
# Numeric input
as_dttm(20220203)
#> [1] "2022-02-03 UTC"
as_dttm(2022020306)
#> [1] "2022-02-03 06:00:00 UTC"
as_dttm(202202030630)
#> [1] "2022-02-03 06:30:00 UTC"
as_dttm(20220203063022)
#> [1] "2022-02-03 06:30:22 UTC"