Given a string of numbers or a POSIXct date-time object, a conversion is done to UNIX time, i.e. seconds since 1970-01-01 00:00:00. The string is assumed to be of the form YYYYMMDD, YYYYMMDDhh, YYYYMMDDhhmm, or YYYYMMDDhhmmss with time zone UTC.
Examples
# Character input
as_unixtime("20220203")
#> [1] 1643846400
as_unixtime("2022020306")
#> [1] 1643868000
as_unixtime("202202030630")
#> [1] 1643869800
as_unixtime("20220203063022")
#> [1] 1643869822
#
# Numeric input
as_unixtime(20220203)
#> [1] 1643846400
as_unixtime(2022020306)
#> [1] 1643868000
as_unixtime(202202030630)
#> [1] 1643869800
as_unixtime(20220203063022)
#> [1] 1643869822
#
# POSIXct input
as_unixtime(Sys.time())
#> [1] 1706885250