I have a Kotlin multiplatform project, and I would like to get the current unixtime in the shared code.
How do you do that in the Kotlin standard library?
Since Kotlin Multiplatform Mobile is now in Beta, we are working on stabilizing the corresponding plugin for Android Studio and will be regularly releasing new versions that include new features, improvements, and bug fixes.
Kotlin multiplatform is a feature released in 2017 with Kotlin 1.2. This feature allows you to write the same code on multiple platforms directly, it focuses on cross-platform app development.
What is Kotlin Multiplatform Mobile? Kotlin Multiplatform Mobile (KMM) is an SDK for cross-platform mobile development. You can develop multiplatform mobile applications and share parts of your applications between Android and iOS, such as core layers, business logic, presentation logic, and more.
It's possible to use the experimental Kotlin datetime library, currently at version 0.1.0
val nowUnixtime = Clock.System.now().epochSeconds
More info here: https://github.com/Kotlin/kotlinx-datetime
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With