How do I create a Unix timestamp on Android?
I want to create a URL post request with a Unix timestamp on the end of the url.
Overview of time and time zones To determine a user's local time for display in locations such as the status bar, Android keeps track of two related but independent states: The current Unix epoch time. The current time zone.
To find the unix current timestamp use the %s option in the date command. The %s option calculates unix timestamp by finding the number of seconds between the current date and unix epoch.
long unixTime = System.currentTimeMillis() / 1000L;
It's quite simple:
long timestamp = Calendar.getInstance().getTime() / 1000;
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