Reputation: 91
How can I get current time in Unix Timestamp format in kotlin as integer?
Upvotes: 7
Views: 10012
Reputation: 427
If you're using Kotlin on the JVM or Android, it's as simple as
val unixTime = System.currentTimeMillis()
for the unix time in milliseconds, or
val unixTime = System.currentTimeMillis() / 1000
for the unix time in seconds (rounded down).
Upvotes: 12