admin 管理员组文章数量: 1086019
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?
1 Answer
Reset to default 9var 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()]);
本文标签: Date conversion and manipulation in javascript with Arabic monthsStack Overflow
版权声明:本文标题:Date conversion and manipulation in javascript with Arabic months - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://roclinux.cn/p/1744072214a2528698.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论