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

# year()

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

## Declaration

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

## Return Value

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

## Discussion

Discussion This example shows an ISO 8601 format with, and without, a year. let meetingDate = Date() // Jun 23, 2021 at 12:51 PM meetingDate.formatted(.iso8601     .year()     .month()     .day() )  // 20210623

meetingDate.formatted(.iso8601     .month()     .day() )  // 0623 The default Date.ISO8601FormatStyle includes the year. 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)
- [month()](foundation/date/iso8601formatstyle/month().md)
- [weekOfYear()](foundation/date/iso8601formatstyle/weekofyear().md)
- [day()](foundation/date/iso8601formatstyle/day().md)
