Kotlin Current Timestamp (KCT)

Hi Dev, the story is I want to get the current time value (current timestamp), for example like this  1320917972 .

System.currentTimeMillis() is a standard "clock" in general (time & date format) to express milliseconds since the past. This clock is also set by your telephone network provider, so unexpectedly sometimes the difference in time zones causes quite astonishing disagreements. I once experienced this when traveling from Jogja to Kalimantan, a difference of 1 hour, almost suspected my watch was broken, damn it.

This clock should only be used when the correspondence has an interest in real-world dates & times, such as a calendar application or alarm clock.

Measurements of time intervals or elapsed time should use different clocks. If using System.currentTimeMillis(), consider using ACTION_TIME_TICK, ACTION_TIME_CHANGED & ACTION_TIMEZONE_CHANGED, which are broadcast intents to know when the time changes.

The conclusion of my problem is to use the following code.

Long tsLong = System.currentTimeMillis()/1000;
String ts = tsLong.toString();

Post a Comment

Previous Next

نموذج الاتصال