Date conversion and manipulation in javascript with Arabic months - Stack Overflow

I want to change an arabic long-form date, i.e.الخميس 26 فبراير 2015(Thursday 26th February, 2015)into

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?

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?

Share Improve this question edited Feb 24, 2015 at 11:18 georg 215k56 gold badges322 silver badges400 bronze badges asked Feb 24, 2015 at 11:09 ArdavionArdavion 1631 silver badge5 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 9
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()]);

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744072213a4553753.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信