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)

4

2 回答 2

2

gps.txt逐行包含unix时间戳(自1970-01-01 00:00:00 UTC以来的秒数)。

$ 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
于 2011-12-18T15:11:55.640 回答
0

您提到的格式的 GPS 时间是从 1980 年 1 月 6 日 00:00:00 开始的秒数。因此,如果您将这些数字除以 31536000(即常规年份的秒数)并加上 1980,您将得到您要查找的年份数。不要忘记有些年份有 366 天,你应该考虑到这一点。以类似的方式,您可以计算月、日、小时等。在所有这些计算之后,您将获得 UTC 格式的 GPS 时间。为了将其转换为 UTC 时间,您必须通过此时有效的 UTC 闰秒数来修复它。

于 2016-05-19T08:22:03.407 回答