toModifiedJulianDate
Signature
Section titled “Signature”toModifiedJulianDate(isoString: string, scale?: TimeScale): number | nullConvert a UTC instant to a Modified Julian Date on a time scale. The scale defaults to "UTC".
- MJD = JD − 2 400 000.5 and counts from midnight, not noon (ITU-R TF.457-2 Rec. 2): midnight is a whole number, and J2000.0 (noon) is 51544.5.
- One double. For present-day dates it keeps about 64 times the resolution of a single-double JD (about 0.6 µs against 40 µs), so it suits a system that takes only one number. The error is at most ½ ulp(MJD) days: 2⁻³⁸ day (0.31 µs) from 1972 to 2038-04-22, 0.63 µs to about 2217, doubling with each later doubling of the MJD, up to 20.1 µs (2⁻³² day) by year 9999, as MJD stays below 2²². For nanoseconds use
toJulianDateParts. - The result is the exact day number plus fraction of the day, rounded once to the nearest double, ties to even; never
JD − 2400000.5in doubles, which would lose the digits MJD exists to keep. - On
"UTC"the count is ERFA’s quasi-MJD: a leap-second day counts as one day, so the difference between two UTC values is not an exact interval (ERFAdtf2d.cNotes 4 and 7). On"TAI","TT"and"TCG"it is read from the labeltoTAI/toTT/toTCGwrites. TDB is not available. - Accepts any offset or bracketed zone, and a listed leap second
…T23:59:60Z. - Domain: 1972-01-01T00:00:00Z to 9999-12-31T23:59:59.999999999Z UTC;
nulloutside it. Within about 20 µs of the end of 9999 (on UTC, TAI and TT) or a fraction of a µs of 1972-01-01 (on TAI and TT) it also returnsnull, because the nearest double lies outside the domain (the last nanosecond of 9999 would give 2973484, which is 10000-01-01) andfromModifiedJulianDatewould reject it;toJulianDatePartscovers the whole domain exactly.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
isoString | string | ISO 8601 instant string |
scale | TimeScale | the time scale to count on, default "UTC" |
Returns
Section titled “Returns”the Modified Julian Date, or null on invalid input, an unknown scale or an instant outside the domain
Related types
Section titled “Related types”Examples
Section titled “Examples”import { toModifiedJulianDate } from "@northguild/gmt/timescale/convert";
toModifiedJulianDate("2000-01-01T00:00:00Z") // 51544Source
Section titled “Source”© 2026 NorthGuild · Licences
Code examples: MIT-0. Packages: MIT. Third-party data and components: their own licences, credited where they appear. Everything else: © 2026 NorthGuild, all rights reserved.