/    Sign up×
Community /Pin to ProfileBookmark

Convert Julian Date to YYYY,MM,DD Format

I am trying to convert Julian Date to YYYY,MM,DD format so that the converted date can be displayed using Full Calender IO (This third party library accepts normal dates and cannt display Julian Date in Calender), Anyone has idea on how to convert Julian date to YYYY,MM,DD format in Javascript? Please help

to post a comment
JavaScript

8 Comments(s)

Copy linkTweet thisAlerts:
@daveyerwinJan 19.2021 — @Manasa1801#1626936

Where does this Julian Date come from ?
Copy linkTweet thisAlerts:
@JMRKERJan 19.2021 — Quick google search and a little modification results in this possibility.

See code comments for references.

<i>
</i>&lt;!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"&gt;
&lt;HTML&gt;
&lt;BODY&gt;
&lt;pre id='demo'&gt;&lt;/pre&gt;

&lt;script language="JavaScript"&gt;
/* Origin of Modified Julian Date (MJD) is 00:00 November 17, 1858 of
the Gregorian calendar
Internal JavaScript built in Date object internal time value 0
milliseconds (ms) is 00:00 January 1, 1970, UT,
equal to MJD 40587
Internal value of MJD origion should be
negative 40587 days * 86,400,000 milliseconds per day =
3,506,716,800,000 ms
*/
// Modified from: https://stackoverflow.com/questions/29627533/conversion-of-julian-date-number-to-normal-date-utc-in-javascript
// for question from: https://www.webdeveloper.com/d/392446-convert-julian-date-to-yyyymmdd-format
var originMJD = -3506716800000, str = '';
str += "Test creation of date object containing origin of MJD.n";
str += new Date(-3506716800000).toUTCString();
str += " should be Wed, 17 Nov 1858 00:00:00 UT.nn";

//Given an MJD display the Gregorian calendar date and time.
var inMJD = 57115;
var inInternal = (inMJD * 86400000) + originMJD;
str += <span><code>Input MJD is ${inMJD}.n</code></span>;
str += "Equivalent Gregorian calendar date and time is ";
str += new Date(inInternal).toUTCString()+".";
document.getElementById('demo').innerHTML = str;

const month2number = (info) =&gt; {
let month = [0,'Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'].indexOf(info);
return month.toString().padStart(2,'0');
}

const Julian2Date = (jdate) =&gt; {
var originMJD = -3506716800000;
// var orig = new Date(-3506716800000).toUTCString(); alert(orig); // for testing purposes only
var ndate = (jdate * 86400000) + originMJD;
let dateStr = new Date(ndate).toUTCString().split(' '); // as long display
let [dd,mm,yyyy] = [dateStr[1],month2number(dateStr[2]),dateStr[3]];
return <span><code>${yyyy}/${mm}/${dd}</code></span>;
}

alert(Julian2Date(0));
alert(Julian2Date(57115));
&lt;/script&gt;
&lt;/BODY&gt;
&lt;/HTML&gt;
Copy linkTweet thisAlerts:
@JennieMillerJan 21.2021 — there is a tool to convert Julian Date format.
Copy linkTweet thisAlerts:
@JMRKERJan 21.2021 — @JennieMiller#1626991 How does your answer help if you don't provide a link or reference to your "tool"?
Copy linkTweet thisAlerts:
@daveyerwinJan 21.2021 — I would like to know where this Julian Date date comes from ?

I would suspect at some point a date in text was converted to Julian Date.
Copy linkTweet thisAlerts:
@marksmith121Jan 25.2021 — We refer to a yyddd date format (yy = year, ddd=day) as a 'Julian Date' - this is the common term for such a date in mainframe and other circles. However technically, a Julian date can mean different things. Astronomers refer to a Julian date as the number of days since the beginning of the Julian Period (January 1, 4713 BC). The Smithsonian Astrophysical Observatory introduced the 'Modified Julian Date' to record the orbit of the Sputnik satellite in 18 bits.

Copy linkTweet thisAlerts:
@johncarryJan 28.2021 — there is a tools to convert. search in google.
Copy linkTweet thisAlerts:
@tome1122Feb 02.2021 — @johncarry#1627305 If you know about this so please send link inbox.
×

Success!

Help @Manasa1801 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 4.24,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,

tipper: @Samric24,
tipped: article
amount: 1000 SATS,
)...