Skip to content Skip to sidebar Skip to footer

Convert Persian Date To Julian Or Gregorian With Keith Wood Calendars

I created a date object with Keith Wood calendar library with Persian instant: var d = $.calendars.newDate(1393, 5, 6, 'persian', 'fa'); Now I need to get Julian or Gregorian dat

Solution 1:

I think toJD() is not what you need:

var d = $.calendars.newDate(1388, 1, 1, 'persian', 'fa');
console.log("Persian date: "+d.toLocaleString()); // Persian date: 1388-01-01var e = d.toJSDate();
console.log(e); // Sat Mar 21 2009 00:00:00 GMT+0100 (Romance Standard Time)

UPDATE: For your comment I see the issue is not solved with this because it transforms the Persian date to your locale date. As far as I can see in the library's reference, there is no way to tell to that function which locale should be used. So the correct way, as the author's provided demo shows, is creating another target calendar and pass the current one as parameter:

var d = $.calendars.newDate(1388, 1, 1, 'persian', 'fa');
var e = $.calendars.newDate(d, 'gregorian', 'fa');

Post a Comment for "Convert Persian Date To Julian Or Gregorian With Keith Wood Calendars"