문제

I'm working in ASP using MVC 4, and i try to know the number of week in month. For example, the user inserts 05/02/2014, and i in controller needs to know the number of week from this date. For example: The user insert 04/02/2014 and i gets result 6

Edit: Using format dd/mm/yyyy

도움이 되었습니까?

해결책

This should solve your problem -

UPDATED With string DateTime conversion

DateTime dt = DateTime.ParseExact("28/02/2014","dd/MM/yyyy", CultureInfo.InvariantCulture);
var cal = System.Globalization.DateTimeFormatInfo.CurrentInfo.Calendar;
cal.GetWeekOfYear(dt, System.Globalization.CalendarWeekRule.FirstDay, System.DayOfWeek.Sunday);
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top