Skip to content

C# Print the ISO 8601 week number

Adrian Sims edited this page Jan 18, 2020 · 2 revisions

This is one liner:

public static int ToIso8601Weeknumber1(this DateTime date)
{
    return 1 + date.AddDays(2 - date.Ticks / 86400 / 10_000_000 % 7) / 7;
}

Clone this wiki locally