<!--
{
  "availability" : [
    "iOS: 7.0.0 -",
    "iPadOS: 7.0.0 -",
    "macCatalyst: 13.1.0 -",
    "macOS: 10.9.0 -",
    "tvOS: 9.0.0 -",
    "visionOS: 1.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "JavaScriptCore",
  "identifier" : "/documentation/JavaScriptCore/JSValue/toDate()",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "JavaScriptCore"
    ],
    "preciseIdentifier" : "c:objc(cs)JSValue(im)toDate"
  },
  "title" : "toDate()"
}
-->

# toDate()

Converts the JavaScript value to a date object.

```
func toDate() -> Date!
```

## Return Value

The date representation of the value.

## Discussion

If the value contains a JavaScript `Date` object, this method returns an equivalent <doc://com.apple.documentation/documentation/Foundation/NSDate> representation. Otherwise, this method uses JavaScript type coercion to interpret the value as a number of seconds and creates an <doc://com.apple.documentation/documentation/Foundation/NSDate> object with the <doc://com.apple.documentation/documentation/Foundation/NSDate/dateWithTimeIntervalSince1970:> method.

---

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)