Converting dates and manipulations in javascript with arabic months

I want to change the date of a long Arabic form, i.e.

الخميس 26 فبراير 2015 (Thursday 26th February, 2015) 

to a standard date using standard Javascript to manipulate the date (add the day) and then display using Date.toLocaleDateString() to convert it by doing

 2015 الخميس 27 فبراير (Friday 27th February, 2015) 

Is this the case when you select a date string separately, interpreting the Arabic text as the month number and creating a new Date () based on numbers, or is there a prototype that converts the Arabic date string to javascript date? What language and optional parameters should be used for Date.toLocaleDateString() to get the same Arabic date format as when using "ar", the numbers are returned in Eastern Arabic, unlike the required Western digits?

+4
source share
1 answer
 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()]); 
+2
source

Source: https://habr.com/ru/post/1260494/


All Articles