15,390,197 members
See more: , +
Please can anyone provide a method to calculate the difference between 2 hijri dates

start date 01/10/1429

End Datem 04/23/1436

Output
7Y 3M 14D

What I have tried:

```function CalculateDate() {
var startDate = "01/10/1429";
var endDate = "04/23/1436";

var sdt = new Date(startDate);
var edt = new Date(endDate);
var difdt = new Date(edt - sdt);
const diffTime = Math.abs(sdt - edt);
const diffDays = Math.ceil(diffTime / (1000 * 60 * 60 * 24));
TotalDays.SetText(diffDays + " Total Days");    <-- total days are more than actual calendar days

alert((difdt.toISOString().slice(0, 4) - 1970) + "Y " + (difdt.getMonth()) + "M " + (difdt.getDate() - 1) + "D");
}
```
Posted
Updated 21-Dec-21 21:55pm
BillWoodruff 22-Dec-21 4:10am

The date data you show here are not Hjri dates ? Is the problem how to convert to Hijri date ?
\$ultaNn 23-Dec-21 4:51am

yes the problems if for hijri dates calculation

## Solution 1

Look at HijriCalendar Class (System.Globalization) | Microsoft Docs[^], especially the ToDateTime() methods.