Epoch & Unix Timestamp in Kotlin
Get the current epoch timestamp
val epochSeconds = java.time.Instant.now().epochSecond Convert epoch to date
val instant = java.time.Instant.ofEpochSecond(1718200000)
val utc = instant.atZone(java.time.ZoneOffset.UTC) Convert date to epoch
val epoch = java.time.LocalDateTime.of(2026, 6, 12, 0, 0)
.toEpochSecond(java.time.ZoneOffset.UTC) Kotlin notes
On the JVM, Kotlin uses java.time directly. For multiplatform code use kotlinx-datetime: Clock.System.now().epochSeconds.
Check any value live with the epoch converter, or read what Unix time actually counts.
Other languages
C · C# · C++ · Dart · Go · Java · JavaScript · MySQL · Perl · PHP · PostgreSQL · Python · R · Ruby · Rust · Scala · SQLite · Swift · TypeScript