Skip to content

Instance Method

startOfDay(for:)

iOS 8.0+ iPadOS 8.0+ Mac Catalyst 8.0+ macOS 10.10+ tvOS 9.0+ watchOS 2.0+
Returns the first moment of a given Date, as a Date.
func startOfDay(for date: Date) -> Date

Parameters

date

The date to search.

Return Value

The first moment of the given date.

Discussion

For example, pass in Date(), if you want the start of today. If there were two midnights, it returns the first. If there was none, it returns the first moment that did exist.