This question already has answers here:
How can I get the DateTime for the start of the week?
(33个答案)
6年前关闭。
我想知道你们是否知道如何根据今天的日期获取当前星期几的日期?
即2009-11-03通过,并且2009-11-02返回
/米
(33个答案)
6年前关闭。
我想知道你们是否知道如何根据今天的日期获取当前星期几的日期?
即2009-11-03通过,并且2009-11-02返回
/米
最佳答案
这就是我使用的(可能不是国际化的):
DateTime input = //...
int delta = DayOfWeek.Monday - input.DayOfWeek;
DateTime monday = input.AddDays(delta);