1. 程式人生 > >c# datetime是一年中的第幾周

c# datetime是一年中的第幾周

cal rule -c rul .get inf static ear urn

public static int WeekOfYear(DateTime dt, CultureInfo ci)
{
return ci.Calendar.GetWeekOfYear(dt, ci.DateTimeFormat.CalendarWeekRule, ci.DateTimeFormat.FirstDayOfWeek);
}

調用:

//weekOfYear 第幾周
int weekOfYear = WeekOfYear(dt_begin, new CultureInfo("zh-CN"));

c# datetime是一年中的第幾周