<!--
{
  "availability" : [
    "iOS: 8.0.0 -",
    "iPadOS: 8.0.0 -",
    "macCatalyst: 13.1.0 -",
    "macOS: 10.10.0 -",
    "tvOS: 9.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 2.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Foundation",
  "identifier" : "/documentation/Foundation/DateIntervalFormatter/string(from:to:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Foundation"
    ],
    "preciseIdentifier" : "c:objc(cs)NSDateIntervalFormatter(im)stringFromDate:toDate:"
  },
  "title" : "string(from:to:)"
}
-->

# string(from:to:)

Returns a formatted string based on the specified start and end dates.

```
func string(from fromDate: Date, to toDate: Date) -> String
```

## Parameters

`fromDate`

The start date. This date appears first in the resulting string.

`toDate`

The end date. This date appears last after the hyphen in the resulting string.

## Return Value

A formatted string representing the specified date interval.

## Discussion

The formatter includes both `fromDate` and `toDate` in the resulting string only when there is enough of a difference in their values to warrant the inclusion of both. If the date and time difference cannot be adequately displayed, the formatter displays one date value. For example, if the [`timeStyle`](/documentation/Foundation/DateIntervalFormatter/timeStyle) property was set to [`DateIntervalFormatter.Style.none`](/documentation/Foundation/DateIntervalFormatter/Style/none), the two dates would need to be at least one day apart in order for both to be displayed.

---

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)