Unix Timestamp in Scala

Use `java.time.Instant` - Scala uses the Java date/time API directly.

Common Operations

Get current Unix timestamp

val ts = java.time.Instant.now().getEpochSecond
// 1706745600

Convert Unix timestamp to Instant

val instant = java.time.Instant.ofEpochSecond(1706745600)

Format as ISO 8601

java.time.Instant.now().toString
// '2024-01-31T22:40:00.123Z'

Other Languages

Need the full converter? Open the Timestamp Converter →