t.vb.w
t.vb.w

Reputation: 117

Milliseconds to UNIX timestamp

Anyone have any idea how I would go about converting a timestamp in milliseconds from 1970 (from Android's System.currentTimeMillis();) to a UNIX timestamp? It need only be accurate to the day.

I figure I could divide by 1000 to get seconds, and then divide by 86400 (number of seconds in a day) to get the # of days. But I'm not sure where to go from there.

Many thanks.

Upvotes: 7

Views: 12810

Answers (3)

Chirag
Chirag

Reputation: 4186

long unixTime = System.currentTimeMillis() / 1000L;

Upvotes: 6

thelost
thelost

Reputation: 6694

Divide it by 1000

Upvotes: 30

C. K. Young
C. K. Young

Reputation: 223023

Dividing by 1000 is enough to get a Unix timestamp. You don't need any numbers of days or anything like that.

Upvotes: 8

Related Questions