I cant figure how to get the yesterday string to swedish culture
DateTime dateTime = DateTime.Now;
string today = dateTime.DayOfWeek.ToString();
string yesterday = dateTime.AddDays(-1).DayOfWeek.ToString(); //Fetch day i.e. Mon, Tues
I have got culture working for todays day, but not yesterday
var culture = new System.Globalization.CultureInfo("sv-SE");
var day = culture.DateTimeFormat.GetDayName(DateTime.Today.DayOfWeek);
Hope someone can help me
You want to use either the ddd
or dddd
custom format specifier with the ToString(string, IFormatProvider)
method.
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);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.