Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to convert the month name in english text in Datetime to arabic text in C#?

Tags:

c#

datetime

I have a date which is displayed as 12 May 2013. I am using the format "dd MMMM yyyy". I want to display the month text i.e May in arabic text. Is there any way? Also, Is there a way to convert the english numbers to arabic numbers in the datetime?

like image 340
Javed Ahmed Avatar asked Feb 19 '23 15:02

Javed Ahmed


1 Answers

Have you tried using an Arabic CultureInfo?

var dateTime = DateTime.Now;
var dateString = dateTime.ToString("dd MMMM yyyy", System.Globalization.CultureInfo.GetCultureInfo("ar"));

ar is the ISO 639 two-letter language code. You can also specify a subculture such as ar-EG for Arabic (Egypt).

like image 85
Andreas Gehrke Avatar answered Apr 27 '23 01:04

Andreas Gehrke