---
title: "setDate(_:animated:)"
framework: uikit
role: symbol
role_heading: Instance Method
path: "uikit/uidatepicker/setdate(_:animated:)"
---

# setDate(_:animated:)

Sets the date to display in the date picker, with an option to animate the setting.

## Declaration

```swift
func setDate(_ date: Date, animated: Bool)
```

## Parameters

- `date`: An NSDate object representing the new date to display in the date picker.
- `animated`: doc://com.apple.documentation/documentation/Swift/true to animate the setting of the new date, otherwise doc://com.apple.documentation/documentation/Swift/false. The animation rotates the wheels until the new date and time is shown under the highlight rectangle.

## See Also

### Managing the date and calendar

- [calendar](uikit/uidatepicker/calendar.md)
- [date](uikit/uidatepicker/date.md)
- [locale](uikit/uidatepicker/locale.md)
- [timeZone](uikit/uidatepicker/timezone.md)
