DayOfWeek 昨天瑞典语

DayOfWeek yesterday swedish

我不知道如何将昨天的字符串转换为瑞典文化

DateTime dateTime = DateTime.Now;
string today = dateTime.DayOfWeek.ToString();
string yesterday = dateTime.AddDays(-1).DayOfWeek.ToString(); //Fetch day i.e. Mon, Tues

我今天有文化,但昨天没有

var culture = new System.Globalization.CultureInfo("sv-SE");
var day = culture.DateTimeFormat.GetDayName(DateTime.Today.DayOfWeek);

希望有人能帮助我

您想将 ddddddd custom format specifierToString(string, IFormatProvider) 方法一起使用。

DateTime dateTime = DateTime.Now;
var culture = new System.Globalization.CultureInfo("sv-SE");
string today = dateTime.ToString("ddd", culture);
string yesterday = dateTime.AddDays(-1).ToString("ddd", culture);