Thought: Based on the DayOfWeek attribute of the DateTime class, we get the English name of the week, and then get the Monday by adding and subtraction of date days.
1. Call:
String today = "2015-7-13";//system.datetime.now.tostring ();
Lblday.text = Getmondayoftheweek (today);
2. Method:
private string Getmondayoftheweek (string today)
{
String smonday = "";
DateTime Datenow;
try{
Datenow= Convert.todatetime (today);
}
Catch
{
Smonday= "Method Getmondayofweeks passed the parameter format error, please check it again after calling! ";
return smonday;
}
String dayofweekname = DateNow.DayOfWeek.ToString ();
int day=0;
Switch (dayofweekname)
{
Case "Monday":
day= 0;
Break
Case "Tuesday":
Day= 1;
Break
Case "Wednesday":
Day= 2;
Break
Case "Thursday":
Day= 3;
Break
Case "Friday":
Day= 4;
Break
Case "Saturday":
Day= 5;
Break
Case "Sunday":
day=6;
Break
}
Smonday = Datenow.adddays (-day). ToString ("yyyy-m-d");
return smonday;
}
. NET gets the current week of Monday (any day of the week that can be extended) based on the input date