Current Week Number
Loading...
Loading...
7
Days in Week
Loading...
Weeks in Year
Loading...
Current Year
Loading...
Days Elapsed
ISO Week Number
Loading...
According to ISO-8601 standard (weeks starting Monday)
Week Start Date
Loading...
First day of the current week (Monday)
Week End Date
Loading...
Last day of the current week (Sunday)
ISO Representation
Loading...
ISO-8601 week date format
About ISO-8601 Week Numbering
The ISO-8601 standard defines weeks as starting on Monday and ending on Sunday. The first week of the year is the week that contains the first Thursday of the year (or equivalently, the week that contains 4 January). This means that the first week of the year always has at least 4 days in the new year. Some years have 53 weeks instead of the usual 52.
Different Week Numbering Systems
ISO-8601 (International)
Week starts: Monday
First week: Contains first Thursday
Used in: Europe, most of the world
First week: Contains first Thursday
Used in: Europe, most of the world
US System
Week starts: Sunday
First week: Contains January 1st
Used in: United States, Canada
First week: Contains January 1st
Used in: United States, Canada
Islamic System
Week starts: Saturday
First week: Contains January 1st
Used in: Middle East, some Islamic countries
First week: Contains January 1st
Used in: Middle East, some Islamic countries
How to Get Current Week Number in Programming
JavaScript
// Get ISO week number
function getISOWeekNumber(date) {
const target = new Date(date.valueOf());
const dayNr = (date.getDay() + 6) % 7;
target.setDate(target.getDate() - dayNr + 3);
const firstThursday = target.valueOf();
target.setMonth(0, 1);
if (target.getDay() !== 4) {
target.setMonth(0, 1 + ((4 - target.getDay()) + 7) % 7);
}
return 1 + Math.ceil((firstThursday - target) / 604800000);
}
const weekNumber = getISOWeekNumber(new Date());
Python
import datetime
# Get ISO week number
week_number = datetime.date.today().isocalendar()[1]
year = datetime.date.today().isocalendar()[0]
print(f"Week {week_number} of {year}")
PHP
// Get ISO week number
$weekNumber = date("W");
$year = date("Y");
echo "Week $weekNumber of $year";
// Or for specific date
$weekNumber = date("W", strtotime("2024-01-15"));
Java
import java.time.LocalDate;
import java.time.temporal.IsoFields;
// Get ISO week number
LocalDate date = LocalDate.now();
int weekNumber = date.get(IsoFields.WEEK_OF_WEEK_BASED_YEAR);
int year = date.get(IsoFields.WEEK_BASED_YEAR);
System.out.println("Week " + weekNumber + " of " + year);
C#
using System;
using System.Globalization;
// Get ISO week number
DateTime date = DateTime.Now;
Calendar calendar = CultureInfo.CurrentCulture.Calendar;
int weekNumber = calendar.GetWeekOfYear(date,
CalendarWeekRule.FirstFourDayWeek,
DayOfWeek.Monday);
Console.WriteLine($"Week {weekNumber}");
Go
package main
import (
"fmt"
"time"
)
func main() {
// Get ISO week number
year, week := time.Now().ISOWeek()
fmt.Printf("Week %d of %d\n", week, year)
}
MySQL
-- Get ISO week number
SELECT WEEKOFYEAR(NOW()) as week_number;
-- Or for specific date
SELECT WEEKOFYEAR('2024-01-15') as week_number;
-- Alternative using WEEK function
SELECT WEEK(NOW(), 3) as week_number;
PostgreSQL
-- Get ISO week number
SELECT EXTRACT(WEEK FROM CURRENT_DATE) as week_number;
-- Or using date_part
SELECT date_part('week', CURRENT_DATE) as week_number;