Epoch & Unix Timestamp in R
Get the current epoch timestamp
epoch_seconds <- as.integer(Sys.time()) Convert epoch to date
dt <- as.POSIXct(1718200000, origin = "1970-01-01", tz = "UTC") Convert date to epoch
epoch <- as.integer(as.POSIXct("2026-06-12", tz = "UTC")) R notes
POSIXct stores fractional seconds since the epoch internally. Always pass tz explicitly — the default is the session's locale timezone, which varies by machine.
Check any value live with the epoch converter, or read what Unix time actually counts.
Other languages
C · C# · C++ · Dart · Go · Java · JavaScript · Kotlin · MySQL · Perl · PHP · PostgreSQL · Python · Ruby · Rust · Scala · SQLite · Swift · TypeScript