2014-03-28 91 views

回答

1

嘗試

var currCulture = CultureInfo.CurrentCulture; 

var weekNo = currCulture.Calendar.GetWeekOfYear(
      new DateTime(2014, 28, 03), //Any date 
      currCulture.DateTimeFormat.CalendarWeekRule, 
      currCulture.DateTimeFormat.FirstDayOfWeek); 
1

發現這個here。檢查是否有幫助。

DateTime dt = DateTime.Now; 
int weekOfMonth = (dt.Day + ((int)dt.DayOfWeek))/7 + 1; 
1
DateTime dt = DateTime.Today; 
CultureInfo ci = CultureInfo.CurrentCulture; 
int weekNum = ci.Calendar.GetWeekOfYear(dt, CalendarWeekRule.FirstFullWeek, DayOfWeek.Monday); 
weekNum = weekNum/12; 
string weekday = dt.DayOfWeek.ToString(); 

有了這個代碼,你將能夠得到週數和任何日期的一週中的一天.....

相關問題