Skip to contents

This is a convenient wrapper for the YMD..2unix functions

Usage

str_datetime_to_unixtime(str_datetime)

str_datetime_to_datetime(str_datetime)

Arguments

str_datetime

A date-time string - its format is guessed from the number of characters in the string: 8 = YYYYMMDD, 10 = YYYYMMDDHH, 12 = YYYYMMDDHHmm. May be passed as a character string or numeric.

Value

The unix time in seconds since 01/01/1970 00:00:00

Examples

str_datetime_to_unixtime("20170101")
#> [1] 1483228800
str_datetime_to_unixtime(2017010112)
#> [1] 1483272000
str_datetime_to_unixtime("201701011230")
#> [1] 1483273800

str_datetime_to_datetime("20170101")
#> [1] "2017-01-01 UTC"
str_datetime_to_datetime(2017010112)
#> [1] "2017-01-01 12:00:00 UTC"
str_datetime_to_datetime("201701011230")
#> [1] "2017-01-01 12:30:00 UTC"