Getting a short day name

前端 未结 5 2302
一生所求
一生所求 2021-02-18 13:51

I was wondering on how to write a method that will return me a string which will contain the short day name, example:

    public static string GetShortDayName(Da         


        
5条回答
  •  北荒
    北荒 (楼主)
    2021-02-18 14:12

    try:

    CultureInfo english = new CultureInfo("en-US");
    string sunday = (english.DateTimeFormat.DayNames[(int)DayOfWeek.Sunday]).Substring(0, 2);
    

    Or:

    dateTimeFormats = new CultureInfo("en-US").DateTimeFormat;
    string sunday = (dateValue.ToString("ffffdd", dateTimeFormats)).Substring(0, 2);
    

提交回复
热议问题