2

I have a millions of GPS data records that I wanted to use for some statistical analysis. Unfortunately there is a field called GPSTime that contains data like: 1320303210, 1318118326, 1302167205.

I believe this is GPS date and time. Could any one assist on how to convert such numbers to normal timestamp (dd-mm-yyyy hh:mm:ss)

James Obuhuma
  • 397
  • 3
  • 8
  • 20

2 Answers2

2

gps.txt contains unix timestamp(seconds since 1970-01-01 00:00:00 UTC) line by line.

$ cat gps.txt
1320303210
1318118326
1302167205

$ while read d; do date -ud @$d '+%F %T'; done <gps.txt
2011-11-03 06:53:30
2011-10-08 23:58:46
2011-04-07 09:06:45

$ TZ=UTC awk '{print strftime("%F %T", $1)}' gps.txt
2011-11-03 06:53:30
2011-10-08 23:58:46
2011-04-07 09:06:45
kev
  • 155,172
  • 47
  • 273
  • 272
0

GPS time in format you mentioned is number of seconds from 6 Jan 1980 00:00:00. So if you divide these numbers by 31536000 which is number of seconds in regular year and add 1980 you will get number of year that you are looking for. Don't forget that some years have 366 days and you should take it into account. In similar way you can calculate month, day, hour and etc. After all these calculation you will get GPS time in UTC format. In order to translate it into UTC time you have to fix it by number of UTC leap seconds that were valid at this time.

Eli
  • 1