---
title: toDate()
framework: javascriptcore
role: symbol
role_heading: Instance Method
path: javascriptcore/jsvalue/todate()
---

# toDate()

Converts the JavaScript value to a date object.

## Declaration

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

## Return Value

Return Value The date representation of the value.

## Discussion

Discussion If the value contains a JavaScript Date object, this method returns an equivalent NSDate representation. Otherwise, this method uses JavaScript type coercion to interpret the value as a number of seconds and creates an NSDate object with the dateWithTimeIntervalSince1970: method.

## See Also

### Reading and Converting JavaScript Values

- [toObject()](javascriptcore/jsvalue/toobject().md)
- [toObjectOf(_:)](javascriptcore/jsvalue/toobjectof(_:).md)
- [toBool()](javascriptcore/jsvalue/tobool().md)
- [toDouble()](javascriptcore/jsvalue/todouble().md)
- [toInt32()](javascriptcore/jsvalue/toint32().md)
- [toUInt32()](javascriptcore/jsvalue/touint32().md)
- [toNumber()](javascriptcore/jsvalue/tonumber().md)
- [toString()](javascriptcore/jsvalue/tostring().md)
- [toArray()](javascriptcore/jsvalue/toarray().md)
- [toDictionary()](javascriptcore/jsvalue/todictionary().md)
- [toPoint()](javascriptcore/jsvalue/topoint().md)
- [toRange()](javascriptcore/jsvalue/torange().md)
- [toRect()](javascriptcore/jsvalue/torect().md)
- [toSize()](javascriptcore/jsvalue/tosize().md)
