Get current time in Unix Timestamp Kotlin?

Viewed 95

How can I get current time in Unix Timestamp format in kotlin as integer?

1 Answers

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).

Related