---
title: weekOfYear()
framework: foundation
role: symbol
role_heading: Instance Method
path: foundation/date/iso8601formatstyle/weekofyear()
---

# weekOfYear()

Modifies the ISO 8601 date format style to include the week of the year in the formatted output.

## Declaration

```swift
func weekOfYear() -> Date.ISO8601FormatStyle
```

## Return Value

Return Value An ISO 8601 date format style modified to include the week of the year.

## Discussion

Discussion The following example shows an ISO 8601 format with, and without, a week of the year. let meetingDate = Date() // Jun 23, 2021 at 12:51 PM meetingDate.formatted(.iso8601     .year()     .month()     .weekOfYear() ) // 202106W25

meetingDate.formatted(.iso8601     .year()     .month()     .day()     .weekOfYear() ) // 202106W2504

meetingDate.formatted(.iso8601     .year()     .day()     .weekOfYear() ) // 2021W2504 When the format style includes the week of year, the output represents the day as the ordinal day of the week. The default Date.ISO8601FormatStyle includes the month. For more information about formatting dates, see the Date.FormatStyle.

## See Also

### Modifying Dates in an ISO 8601 Format Style

- [dateSeparator(_:)](foundation/date/iso8601formatstyle/dateseparator(_:).md)
- [year()](foundation/date/iso8601formatstyle/year().md)
- [month()](foundation/date/iso8601formatstyle/month().md)
- [day()](foundation/date/iso8601formatstyle/day().md)
