A javascript Date object with Hebrew calendar context
npm install he-date
You can also use without downloading:
<script src="https://unpkg.com/he-date"></script>`
HeDate methods are just like the native Date
methods, but instead of Gregorian calendar, it
uses the Hebrew calendar.
If you are familliar with the native Date
, you can quickly get started with HeDate
.
var HeDate = require('he-date'); // for node.js
var heDate = new HeDate(5777, 5, 15);
console.log(heDate.getMonth()) // 5
console.log(heDate.toDateString()) // Mon 15 Adar 5777
For complete method reference, see the Docs.
For only converting Gregorian date to Hebrew date, you could use the native method as follow:
new Date().toLocaleDateString('en-US-u-ca-hebrew')
However, you couldn't convert Hebrew date to Gregorian date.
That is why you need HeDate.
Further more, the native method is not 100% correct!
For example, try to compare the result of the following code:
new Date(2046, 9, 1).toLocaleDateString('en-US-u-ca-hebrew')
against Google Calendar equivalent.
Hebcal is a reach library for managing hebrew dates.
The difference between Hebcal and HeDate:
- HeDate uses the native
Date
methods, while Hebcal provides its own functions. - Hebcal provides you with very much methods that you will generally don't need at all (i.e.
getSedra
).
Also, it takes your location to calculate sunrise and sunset.
HeDate doesn't provide any additional functions other than theDate
like methods.
So, if you want to know only about hebrew dates, months and years, then prefer HeDate.
But if you want also to know about hebrew holidays, Sedra's, sunrise, DafYomi and so on, you may
try Hebcal.