fromEpochMilliseconds

actual fun fromEpochMilliseconds(epochMilliseconds: Long): Instant(source)
expect fun fromEpochMilliseconds(epochMilliseconds: Long): Instant(source)

Returns an Instant that is epochMilliseconds number of milliseconds from the epoch instant 1970-01-01T00:00:00Z.

Every value of epochMilliseconds is guaranteed to be representable as an Instant.

Note that Instant also supports nanosecond precision via fromEpochSeconds.

See also

Samples

import kotlinx.datetime.*
import kotlinx.datetime.format.*
import kotlin.random.*
import kotlin.test.*
import kotlin.time.Duration.Companion.hours

fun main() { 
   //sampleStart 
   // Constructing an Instant from the number of milliseconds since the Unix epoch
check(Instant.fromEpochMilliseconds(epochMilliseconds = 0) == Instant.parse("1970-01-01T00:00:00Z"))
check(Instant.fromEpochMilliseconds(epochMilliseconds = 1_000_000_000_123)
    == Instant.parse("2001-09-09T01:46:40.123Z")) 
   //sampleEnd
}
actual fun fromEpochMilliseconds(epochMilliseconds: Long): Instant(source)