Pavel
Pavel

Reputation: 813

kotlin-multiplatform timestamp to time in milliseconds (unix time)

I'm using kotlin-multiplatform for iOS and Android targets.

I'm deserializing json string with timestamp inside: 2020-01-16T11:33:34.553Z

I would like to convert this timestamp to time in milliseconds (unix time). Is it possible to do this using kotlin native libraries?

I'm using kotlin multiplatform 1.3.72.

Upvotes: 1

Views: 2209

Answers (1)

Toad Frogson
Toad Frogson

Reputation: 1

Yes, you can do it with native kotlin libs like this:

timeValue.toInstant().epochSeconds

where toInstant() is a function in the kotlinx.datetime library.

Upvotes: 0

Related Questions