DateTime型別中獲取DayOfWeek時的英文如何轉換成中文?
1.這是一種最笨的方法 int i=(int)DateTime.Today.DayOfWeek; switch(i) { case 0: txtDate.Text="星期天"; break; case 1: txtDate.Text="星期一"; break; case 2: txtDate.Text="星期二"; break; case 3: txtDate.Text="星期三"; break; case 4: txtDate.Text="星期四"; break; case 5: txtDate.Text="星期五"; break; …………………… }
2.聰明的方法:
string strWeek = "星期"+"日一二三四五六".Substring((int)System.DateTime.Now.DayOfWeek,1);
3.最好的方法:
string dateString = System.DateTime.Today.ToString("yyyy-M-d dddd", new System.Globalization.CultureInfo("zh-CN"));