GPS time conversion, in brief
GPS time is a continuous time scale counted from the GPS epoch. This example converts a calendar timestamp already expressed in GPS time into Julian Date, GPS week and seconds-of-week. Converting a UTC timestamp first requires the applicable GPS−UTC offset; that is a separate operation.
Learning objectives
- Extract date-time components for GNSS processing.
- Compute Julian Date with the Gregorian calendar formula.
- Convert elapsed GPS seconds into seconds-of-week.
Why GPS time is the first numerical dependency
Every observation equation needs a time tag. RINEX observations, broadcast navigation records, SP3 epochs, satellite clocks, and Earth rotation corrections all depend on consistent time handling.
GPS time starts at 1980-01-06 00:00:00 GPST and is handled as a continuous count. This example assumes the calendar timestamp is already expressed in GPST; convert UTC with the epoch-appropriate leap-second offset before applying these steps. In many single-epoch algorithms, the useful quantity is seconds-of-week.
Step 1
Extract the date-time components
For the example timestamp `2024-01-01 01:59:44`, split the string into integer components.
Step 2
Compute the Julian Date
Use the Gregorian calendar conversion. The time-of-day term shifts the day boundary to noon, which is standard for Julian Date.
Step 3
Convert Julian Date to GPS seconds-of-week
Subtract the GPS epoch Julian Date, multiply by seconds per day, then reduce modulo one GPS week.
Minimal implementation
from datetime import datetime
def gps_seconds_of_week(value: str) -> float:
dt = datetime.strptime(value.split('.')[0], '%Y-%m-%d %H:%M:%S')
a = (14 - dt.month) // 12
y = dt.year + 4800 - a
m = dt.month + 12 * a - 3
jd = dt.day + ((153 * m + 2) // 5) + 365 * y + y // 4 - y // 100 + y // 400 - 32045
jd += (dt.hour - 12) / 24 + dt.minute / 1440 + dt.second / 86400
return ((jd - 2444244.5) * 86400) % 604800
Common mistake
Do not mix GPS Time and UTC without accounting for leap seconds. For RINEX/SP3 workflows, always verify which time scale the file uses before combining records.
Result
Computed result
93584.00001978874 s
The timestamp falls at about 93,584 seconds into the GPS week.
What you should understand now
- GPS seconds-of-week is a modulo-reduced time variable.
- Julian Date conversion is deterministic but easy to shift by 12 hours if the time fraction is handled incorrectly.
- This time value becomes an input to satellite clock, orbit, and interpolation steps.
Related tutorials
Observations and files
RINEX Observation Basics
A practical map of a RINEX 3 observation file, including headers, observation type codes, and epoch records.
Satellite orbits and ephemerides
Keplerian Elements in GPS Navigation Messages
A numerical map of GPS broadcast ephemeris fields: clock parameters, orbit shape, harmonic corrections, time references, and hardware delays.
Help improve this tutorial
Point out numerical ambiguity, missing prerequisites, or a step that needs a fuller derivation.