Back To Overview
Convert GPS time to UNIX time
Posted on 30 Jun, 2011 by PaulSmith
Hello,

What I want to do is very simple. I want to convert a GPS time measurement into a UNIX time measurement, where GPS time is the number of seconds since Jan 6, 1980 00:00:00 UTC etc.

When looking at the available routines, I see lots of routines which require things like "GPS Week", "GPSZcount" etc, but not a single time conversion routine which accepts a normal GPS time input. This seems very strange to me and maybe I'm missing something.

If GPSTk cannot do this, can someone recommend another library that can?

Add your comments to the Discussion
 

Hello Paul,

Because both GPS time and Unix time are counted as number of seconds from a specific date, and ignore leap-seconds, to obtain Unix time from a GPS time you must add the number of seconds between the beginning of Unix time and the beginning of GPS time to the GPS time value to obtain the Unix time. So the conversion is very straightforward, just adding a constant value to the GPS time. The GPSTk can help you obtain this constant by using the timeconvert application to convert the start of GPS time to Unix time, as in:

timeconvert -c "01 06 1980"


And your output should look like this, with Unix seconds (and microseconds) on the 6th line:


Month/Day/Year H:M:S 01/06/1980 00:00:00
Modified Julian Date 44244.000000000
GPSweek DayOfWeek SecOfWeek 0 0 0.000000
FullGPSweek Zcount 0 0
Year DayOfYear SecondOfDay 1980 006 0.000000
Unix: Second Microsecond 315964800 0
Zcount: 29-bit (32-bit) 0 (0)

Add this value (315964800) to the GPS time (in seconds) to get the corresponding Unix time.

Hope this helps, and good luck!

-- Susan Cummins
SusanCummins 01 Jul 2011 - 10:17



Topic revision: r2 - 01 Jul 2011, SusanCummins
 

This site is powered by FoswikiCopyright © by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding Foswiki? Send feedback