Bridouille / android-beacon-scanner

A simple android iBeacon, AltBeacon, Eddystone and RuuviTag beacon scanner
https://play.google.com/store/apps/details?id=com.bridou_n.beaconscanner
331 stars 108 forks source link

Formate of the lastSeen field #8

Closed PascalMinder closed 7 years ago

PascalMinder commented 7 years ago

What type of format has the lastSeen file if I use the logging function

Bridouille commented 7 years ago

The lastSeen field is a timestamp in milliseconds (long) representing the date when the beacon has been scanned for the last time!

PascalMinder commented 7 years ago

I know that, but what I didn't know was, that the time is a unix timestamp with the ms added to it.

    // calculate timestamp
    $msTime = $lastSeen % 1000;
    $unixTime = ($lastSeen - $msTime) / 1000;
Bridouille commented 7 years ago

Yep exactly.

A much simpler version would be to only remove the miliseconds if you want the time in seconds : $unixTime = $lastSeen / 1000

Small note on this one, the timestamp is taken in the timezone from where the phone is setup.