Converts a Unix timestamp to a POSIXct datetime value

from_unix_timestamp(ts, tz = "UTC")

Arguments

ts

(character or numeric): Unix timestamps, including milliseconds.

tz

(character): timezone of the returned datetime values. Defaults to UTC.

Value

A POSIXct datetime value in the format %Y-%m-%d %H:%M:%S.

Examples

ts1 <- 60 * 60 * 24 * 1000 ts2 <- as.character(60 * 60 * 24 * 1000) from_unix_timestamp(ts1, tz = "UTC")
#> [1] "1970-01-02 UTC"
from_unix_timestamp(ts2, tz = "UTC")
#> [1] "1970-01-02 UTC"