As i search, unfortunately umbraco does not support Persian
date time forma but you can study FormatDateTime and change the appearance to format like yyyy/mm/dd
but for full name of months like فروردین
اردیبهشت
you should create your own control or use other staff like PersianDate® (PD)
In case of code to develop a custom control you can study PersianCalendar Class
and this tiny solution :^)
if your date is a Gregorian date then First you must convert it to Jalali date like this:
PersianCalendar jc = new PersianCalendar();
DateTime date = new DateTime(jc.GetYear(d), jc.GetMonth(d), jc.GetDayOfMonth(d));
string print = string.Format("{0:0000}/{1:00}/{2:00}", date.Year, date.Month, date.Day);
but if your date is a Jalali date already then just use:
string print = string.Format("{0:0000}/{1:00}/{2:00}", date.Year, date.Month, date.Day);
now if you have a string contains a Jalali date like "1390/12/10" and you want to get its day name it ll be a bit tricky.
public static string GetDayOfWeekName(this DateTime date)
{
PersianCalendar jc = new PersianCalendar();
DateTime d = jc.ToDateTime(date.Year, date.Month, date.Day, 0, 0, 0, 0, PersianCalendar.PersianEra);
switch (d.DayOfWeek)
{
case DayOfWeek.Saturday: return "شنبه";
case DayOfWeek.Sunday: return "يکشنبه";
case DayOfWeek.Monday: return "دوشنبه";
case DayOfWeek.Tuesday: return "سه شنبه";
case DayOfWeek.Wednesday: return "چهارشنبه";
case DayOfWeek.Thursday: return "پنجشنبه";
case DayOfWeek.Friday: return "جمعه";
default: return "";
}
First you Should convert it to Gregorian Date then get the Day Name.
but not for Months name:
public static string GetMonthName(this DateTime date)
{
switch (date.Month)
{
case 1: return "فررودين";
case 2: return "ارديبهشت";
case 3: return "خرداد";
case 4: return "تير";
case 5: return "مرداد";
case 6: return "شهريور";
case 7: return "مهر";
case 8: return "آبان";
case 9: return "آذر";
case 10: return "دي";
case 11: return "بهمن";
case 12: return "اسفند";
default: return "";
}
}
i would be appreciated if i could provide you more useful post and please let me know it!