<!--
{
  "availability" : [
    "iOS: 13.0.0 -",
    "iPadOS: 13.0.0 -",
    "macCatalyst: 13.1.0 -",
    "macOS: 10.15.0 -",
    "tvOS: 13.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 6.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Foundation",
  "identifier" : "/documentation/Foundation/RelativeDateTimeFormatter/string(for:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Foundation"
    ],
    "preciseIdentifier" : "c:objc(cs)NSRelativeDateTimeFormatter(im)stringForObjectValue:"
  },
  "title" : "string(for:)"
}
-->

# string(for:)

Creates a formatted string for a date relative to the current date and time.

```
func string(for obj: Any?) -> String?
```

## Parameters

`obj`

A date object to format.

## Return Value

A string that represents the date interval between a date and the current date and time, or `nil` if obj isn’t an instance of [`NSDate`](/documentation/Foundation/NSDate).

## Discussion

To determine the relative interval, the formatter uses [`date`](/documentation/Foundation/NSDate/date) as the reference date.

---

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)