Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I create a Unix timestamp on Android?

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.

like image 800
iamlukeyb Avatar asked Apr 16 '12 15:04

iamlukeyb


People also ask

Does Android use Unix time?

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.

How do I display a Unix timestamp?

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.


2 Answers

 long unixTime = System.currentTimeMillis() / 1000L; 
like image 59
Nesim Razon Avatar answered Oct 04 '22 04:10

Nesim Razon


It's quite simple:

long timestamp = Calendar.getInstance().getTime() / 1000; 
like image 25
Aleks G Avatar answered Oct 04 '22 05:10

Aleks G