<p>A modified Julian Date is just a Julian Date minus 2,400,000.5.  So you could just add 2,400,000.5 to the MJD, and use existing Julian Date routines to do the conversion.  Here are some routines which break a <a href="https://www.celestialprogramming.com/julian.html" rel="nofollow noreferrer">JD into Month, Day, Year</a> and vice versa.</p>
<p>But, if you're using any modern language which has built in date routines, I highly recommend you use those instead to avoid the many special cases when dealing with dates.</p>
<p>Most languages will accept the time in seconds since Jan 1, 1970 (&quot;Unix Time&quot;) as an input to date routines, and the functions below will convert a MJD to/from Unix Time in milliseconds:</p>
<pre><code>function ModifiedJulianDateFromUnixTime(t){
    return (t / 86400000) + 40587;
}

function UnixTimeFromModifiedJulianDate(jd){
    return (jd-40587)*86400000;
}
</code></pre>
<p>The above functions are in Javascript, but it is trivial to convert to nearly any other language.  Some languages accept seconds rather than milliseconds, so divide by 1000 for those.</p>
<p>For, example, in JavaScript, the code below will get all of the components.</p>
<pre><code>date = new Date(UnixTimeFromModifiedJulianDate(59145.6678));
day=date.getDate();
year=date.getYear()+1900;
month=date.getMonth()+1;
hour=date.getHours();
minutes=date.getMinutes();
seconds=date.getSeconds();
milli=date.getMilliseconds();
console.log(year,month,day,hour,minutes,seconds,milli);
</code></pre>
<p>Returns:</p>
<pre><code>2020 10 23 12 1 37 920
</code></pre>
<p>You must be careful about any dates prior to Oct 15, 1582 (the start of the Gregorian Calendar).  What answer is correct depends a lot on what your intentions are.  The routines in the link above assume anything before the Gregorian Calendar are in the Julian Calendar, which matches what JPL Horizons does.</p>

CC BY-SA 4.0
2022-11-21T04:32:22.147Z
I should note the "getHours()" etc, functions will return values based on the local time zone, while the input is assumed to be UTC.  Use the "getUTCHours()", etc, functions to get the result in UTC.
Greg Miller
CC BY-SA 4.0
2022-11-20T18:50:56.650Z
2022-11-20T18:50:56.650Z
Greg Miller
<p>I looked online and couldn't see an actual formula or anything, so I figured I'd ask here.</p>
<p>If I had an MJD like the following: 59145.6678</p>
<p>How would I convert that to a month, day, and year with the hour and minutes?</p>
<p>Thanks in advance!</p>

CC BY-SA 4.0
2022-11-20T18:54:00.040Z
https://en.wikipedia.org/wiki/Julian_day says MJD 0 is 0:00 November 17, 1858 (UTC). Since you know Python, you can use the standard datetime module to write conversion code.
PM 2Ring
<observational-astronomy><star><telescope><amateur-observing><data-analysis>
How does one convert between Modified Julian Date (MJD) and a standard (mm/dd/yr, hr:mm:ss)
Zachary Kennedy
# How does one convert between Modified Julian Date (MJD) and a standard (mm/dd/yr, hr:mm:ss)

(Asked by: username_0 on 2022-11-20)

I looked online and couldn't see an actual formula or anything, so I figured I'd ask here.

If I had an MJD like the following: 59145.6678

How would I convert that to a month, day, and year with the hour and minutes?

Thanks in advance!

**Tags:** observational-astronomy, star, telescope, amateur-observing, data-analysis
> **Comments:**
> **username_1**: https://en.wikipedia.org/wiki/Julian_day says MJD 0 is 0:00 November 17, 1858 (UTC). Since you know Python, you can use the standard datetime module to write conversion code.  

---

## 1 answers

### Answer by username_2 on 2022-11-20. Score: 4 | Accepted answer

A modified Julian Date is just a Julian Date minus 2,400,000.5.  So you could just add 2,400,000.5 to the MJD, and use existing Julian Date routines to do the conversion.  Here are some routines which break a JD into Month, Day, Year and vice versa.
But, if you're using any modern language which has built in date routines, I highly recommend you use those instead to avoid the many special cases when dealing with dates.
Most languages will accept the time in seconds since Jan 1, 1970 ("Unix Time") as an input to date routines, and the functions below will convert a MJD to/from Unix Time in milliseconds:
function ModifiedJulianDateFromUnixTime(t){
    return (t / 86400000) + 40587;
}

function UnixTimeFromModifiedJulianDate(jd){
    return (jd-40587)*86400000;
}

The above functions are in Javascript, but it is trivial to convert to nearly any other language.  Some languages accept seconds rather than milliseconds, so divide by 1000 for those.
For, example, in JavaScript, the code below will get all of the components.
date = new Date(UnixTimeFromModifiedJulianDate(59145.6678));
day=date.getDate();
year=date.getYear()+1900;
month=date.getMonth()+1;
hour=date.getHours();
minutes=date.getMinutes();
seconds=date.getSeconds();
milli=date.getMilliseconds();
console.log(year,month,day,hour,minutes,seconds,milli);

Returns:
2020 10 23 12 1 37 920

You must be careful about any dates prior to Oct 15, 1582 (the start of the Gregorian Calendar).  What answer is correct depends a lot on what your intentions are.  The routines in the link above assume anything before the Gregorian Calendar are in the Julian Calendar, which matches what JPL Horizons does.

> **Comments:**
> **username_2**: I should note the "getHours()" etc, functions will return values based on the local time zone, while the input is assumed to be UTC.  Use the "getUTCHours()", etc, functions to get the result in UTC.  

---

