How to

get week number

Published: 9. October 2011 | Updated: 12. October 2011
License: Microsoft Public License (MS-PL)
Categories: Globalization » Calendar
Tags: C# DateTime Globalization
Was this snippet helpful for you? YESYES / NONO

Import namespace

using System.Globalization;

Code

var culture = CultureInfo.GetCultureInfo("cs-CZ");
var dateTimeInfo = DateTimeFormatInfo.GetInstance(culture);

var dateTime = DateTime.Today;

int weekNumber = culture.Calendar.GetWeekOfYear(dateTime, dateTimeInfo.CalendarWeekRule, dateTimeInfo.FirstDayOfWeek);
Send us feedback about this snippet »



Related Snippets: