Esh Esh - 7 months ago 23
Javascript Question

Calculating Jday(Julian Day) in javascript

I have requirement to calculate

jday
in javascript , for doing client side validation , Can any one help me how to calculate
JDAY
in javascript or script to change given JDAY to actual date or vice versa .

To know what is JDay ,I found the following site ,

http://www.pauahtun.org/Software/jday.1.html

Am also refering the below site for calculation which is mentioned in JAVA

http://www.rgagnon.com/javadetails/java-0506.html

Thank you in advance

Answer

If what you're looking for is the julian day that would equal 2456141 today, or in other words the number of days since the beginning of the Julian period :

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

var today = new Date(); //set any date
var julian = today.getJulian(); //get Julian counterpart 

FIDDLE

The day of the year is normally reffered to as a Julian Date, not Day.