I want to change an arabic long-form date, i.e.
الخميس 26 فبراير 2015
(Thursday 26th February, 2015)
into a standard date using standard Javascript in order to manipulate the date (add a day), then display via Date.toLocaleDateString()
to convert it back, making
2015 الخميس 27 فبراير
(Friday 27th February, 2015)
Is this a case of picking the date string apart, interpreting the arabic text as a month number and creating a new Date() given the numbers, or is there a prototype that converts an arabic date string into a javascript date? What language and optional parameters need to be used for Date.toLocaleDateString()
to produce the same format of arabic date, as using 'ar' the numbers are returned in eastern arabic, as opposed to the required western numerals?
var months = ["يناير", "فبراير", "مارس", "إبريل", "مايو", "يونيو",
"يوليو", "أغسطس", "سبتمبر", "أكتوبر", "نوفمبر", "ديسمبر"];
var days =["اﻷحد","اﻷثنين","الثلاثاء","اﻷربعاء","الخميس","الجمعة","السبت"];
var date = new Date();
console.log("The current month is " + months[date.getMonth()]);
console.log("The current day is " + days[date.getDay()]);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With