<!--
{
  "availability" : [
    "iOS: 8.0.0 -",
    "iPadOS: 8.0.0 -",
    "macCatalyst: 13.1.0 -",
    "macOS: 10.9.0 -",
    "tvOS: 9.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 2.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Foundation",
  "identifier" : "/documentation/Foundation/NSCalendar/date(bySettingHour:minute:second:of:options:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Foundation"
    ],
    "preciseIdentifier" : "c:objc(cs)NSCalendar(im)dateBySettingHour:minute:second:ofDate:options:"
  },
  "title" : "date(bySettingHour:minute:second:of:options:)"
}
-->

# date(bySettingHour:minute:second:of:options:)

Creates a new date calculated with the given time.

```
func date(bySettingHour h: Int, minute m: Int, second s: Int, of date: Date, options opts: NSCalendar.Options = []) -> Date?
```

## Parameters

`h`

The hour value.

`m`

The minute value.

`s`

The second value.

`date`

The date to use to perform the calculation.

`opts`

Options for the calculation. For possible values, see [`NSCalendar.Options`](/documentation/Foundation/NSCalendar/Options).

## Return Value

A new `NSDate` instance representing the date calculated by setting the given hour, minute, and second, to a given time. If no such time exists for the specified components, the next available date is returned, which may be on a different calendar day.

## Discussion

You can use this method to calculate a date at a different time of a particular calendar day.

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)