Contents

startOfDay(for:)

Returns the first moment of a given date as a date instance.

Declaration

func startOfDay(for date: Date) -> Date

Parameters

  • date:

    The date for which to perform the calculation.

Return Value

An NSDate instance representing the first moment date of the given date.

Discussion

For example, passing [NSDate date] for the date parameter would give you the start of “today.”

Special Considerations

If there were two midnights, this method returns the first. If there was none, it returns the first moment that did exist.

See Also

Scanning Dates