我有特定年份的出生日期,我想找到当年出生日期的日期名称。
怎么做?
答案 0 :(得分:5)
你可以在今年找到生日,比如;
var birthDate = new DateTime(1983, 10, 21);
var thisYear = new DateTime(DateTime.Today.Year, birthDate.Month, birthDate.Day);
var dayOfWeek = thisYear.DayOfWeek; // it gives you day of week of birth day in this year
答案 1 :(得分:3)
答案 2 :(得分:1)
使用
string day = DateTime.Now.DayOfWeek.ToString();
答案 3 :(得分:0)
试试这个
string Name = CultureInfo.CurrentCulture.DateTimeFormat.GetDayName(DateTime.Now.DayOfWeek);
提供帮助
答案 4 :(得分:0)
我使用此扩展方法:
var birthDate = new DateTime(1983, 10, 21);
var thisYear = new DateTime(DateTime.Today.Year, birthDate.Month, birthDate.Day);
var dayOfWeek = thisYear.GetDayName(); //<- Returns 'Monday'
然后我们称之为:
Shift_Monday_Target