Julian Date

The Julian date is simply the day of the year and the current year concatenated together. Once you have added the getDOY() method to all your dates it is trivial to be able to construct the current Julian date simply by concatenating the two values. Note that we concatenate them to an empty string in order to ensure that the + operator concatenates the values rather than adding them together.

juldate = "" + mydate.getDOY()) + mydate.getFullYear();

Being able to convert a Julian date back into a Date object turns out to be even easier even though a Julian date is not one of the values that can be used to create a date object directly. We simply take advantage of the fact that when you create a Date object by specifying a year, month and day that it doesn't matter if the day number is outside the valid range since it treats each value as an offset. So simply specifying January as the month and passing the day of the year in as the day we automatically get the correct date being set just as if we had passed it the month and day of the month. The simplest way is to create a new jDate() function that takes the Julian date as a parameter and returns a Date object containing that date.

jDate = function(jd) {
return new Date(js%10000,0,Math.floor(jd/10000));


This article written by Stephen Chapman, Felgall Pty Ltd.

go to top

FaceBook Follow
Twitter Follow