Julian Day

The Julian day (not to be confused with Julian Date) is simply a count of the number of days since a specific start date. The start date was selected so that all of our historical period comes after that start date and so any date in history can be identified as having occurred on a positive Julian Day. Noon GMT on 1st January 4713BC was selected as the zero point. Julian days can have a decimal portion that indicates the fraction of the day that has passed since noon GMT. The reason for selecting noon is that this date format is commonly used by astronomers who would prefer to not have the day number change right in the middle of their work period.Since the Julian day is just a sequence of days from a given date and JavaScript Date objects are stored as the number of milliseconds from a given date you would expect that converting a Date into a Julian day would be just a matter of dividing the Date's internal value by the number of milliseconds in a day and then adding the Julian day number corresponding to 1st January 1970 (which is the date that JavaScript uses as its zero point, the same as Unix does) but because one date starts from noon in a specific timezone and the other starts from midnight in a local timezone we also need to adjust for the timezone offset.

Date.prototype.getJulian = function() {
return Math.floor((this / 86400000) - (this.getTimezoneOffset()/1440) + 2440587.5);


This article written by Stephen Chapman, Felgall Pty Ltd.

go to top

FaceBook Follow
Twitter Follow