DateTime.getWeekOfYear

Returns the ISO 8601 week number for the week containing datetime. The ISO 8601 week number is the same for every day of the week (from Moday through Sunday). That can produce some unusual results (described below).

The first week of the year is week 1. This is the week that contains the first Thursday of the year. Equivalently, this is the first week that has more than 4 of its days falling within the calendar year.

The value 0 is never returned by this function. Days contained within a year but occurring before the first ISO 8601 week of that year are considered as being contained in the last week of the previous year. Similarly, the final days of a calendar year may be considered as being part of the first ISO 8601 week of the next year if 4 or more days of that week are contained within the new year.

class DateTime
int
getWeekOfYear
()

Return Value

Type: int

the ISO 8601 week number for datetime.

Meta

Since

2.26