flawr
flawr

Reputation: 11628

get current julian day

I need to get the julian day of an arbitrary date in javascript (it should work for about +-50 years from now) for calculating the position of the sun. What is the easisest way in javascript to get that number, or is there already a method? Thank you

SOLVED: sdespont posted a good link

Upvotes: 0

Views: 698

Answers (1)

Douglas G. Allen
Douglas G. Allen

Reputation: 2261

When I first wanted to know about finding sunrise and sunset times I was looking for answers on wikipedia but I'm no math wizard. I couldn't understand the formula, well maybe just a little. I knew that you needed to be able to iterate something from 0 to whatever the limit was. But what I had found outside of those was a web page to calculate the very formula that I had been seeing in Greek. Here is that web page. Looking at examples is not stealing in my mind. There are many other sites similar to this on the net. Some use Javascript others use Perl and PHP.

<img src="https://wikimedia.org/api/rest_v1/media/math/render/svg/45e26774ace10d6eb58299c5adcab50958a53d61" class="mwe-math-fallback-image-inline mw-math-element" aria-hidden="true" style="vertical-align: -2.505ex; width:70.501ex; height:6.176ex;" alt="&#10;J\!D\!N = &#10;\text{day} + &#10;\left\lfloor\frac{153m+2}{5}\right\rfloor +&#10;365y+&#10;\left\lfloor\frac{y}{4}\right\rfloor -&#10;\left\lfloor\frac{y}{100}\right\rfloor +&#10;\left\lfloor\frac{y}{400}\right\rfloor -&#10;32045&#10;" />

Upvotes: 1

Related Questions