Converts a POSIXct datetime to Unix timestamp

to_unix_timestamp(datetime, tz = "UTC")

Arguments

datetime

Either a POSIXct datetime value or a character value that can be coerced into such a POSIXct datetime value. Expected format: %Y-%m-%d %H:%M:%S. If datetime is a character value, then hours, minutes, and seconds must be provided explicitly (so, for example, a value of "2010-01-01 00:00:00" will work, while "2010-01-01" will throw an error).

tz

Character value corresponding to the timezone of datetime. Defaults to UTC.

Value

A character value that corresponds to a Unix timestamp.

Details

All Unix timestamps returned by this function have a millisecond-level precision.

Examples

dt <- "2019-01-01 00:00:10" to_unix_timestamp(datetime = dt, tz = "UTC")
#> [1] "1546300810000"