Date time week

xiaoxiao2021-03-31  185

// Monday this week

public static DateTime CalculateFirstDateOfWeek (DateTime someDate) {someDate = Convert.ToDateTime (someDate.ToShortDateString ()); int i = someDate.DayOfWeek - DayOfWeek.Monday; if (i == -1) i = 6; TimeSpan ts = new TimeSpan (i, 0, 0, 0); return somedate.subtract (ts);

// next Tuesday format string public static string getNextTuesDay (DateTime someDate) {DateTime thisMonDay = CalculateFirstDateOfWeek (someDate); TimeSpan ts = new TimeSpan (8,0,0,0); DateTime nextTues = thisMonDay.AddDays (8);

String stryear = nexttues.year.tostring (); string strMonth = nexttues.month.toString (); if (convert.Toint32 (strMonth) <10) {strmonth = "0" strMonth;} string strDay = nexttues.day. Tostring (); if (Convert.Toint32 (strDay) <10) {strDay = "0" strDay;} string b = strers

转载请注明原文地址:https://www.9cbs.com/read-130818.html

New Post(0)