# Datetime

Datetime wrapper for SurrealDB datetime values.

A `Datetime` wraps an ISO 8601 datetime string for use with SurrealDB's `datetime` type. It preserves the original string representation through serialisation and deserialisation.

```python title="Import"
from surrealdb import Datetime
```

---

## Constructor {#constructor}

```python title="Syntax"
Datetime(dt)
```

<table>
    <thead>
        <tr>
            <th>Parameter</th>
            <th>Type</th>
            <th>Description</th>
        </tr>
    </thead>
    <tbody>
        <tr>
            <td><code>dt</code> _(required)_</td>
            <td><code>str</code></td>
            <td>An ISO 8601 datetime string.</td>
        </tr>
    </tbody>
</table>

### Examples

```python
dt = Datetime("2025-01-15T10:30:00Z")
```

```python
dt = Datetime("2025-06-01T14:00:00.000+02:00")
```

---

## Properties {#properties}

| Property | Type | Description |
|---|---|---|
| `dt` | `str` | The ISO 8601 datetime string. |

```python
dt = Datetime("2025-01-15T10:30:00Z")
print(dt.dt)  # "2025-01-15T10:30:00Z"
```

---

## Usage {#usage}

```python
from surrealdb import Surreal, RecordID, Datetime

db = Surreal("ws://localhost:8000")
db.connect()
db.use("my_ns", "my_db")
db.signin({"username": "root", "password": "secret"})

db.create("events", {
    "title": "Launch",
    "scheduled_at": Datetime("2025-06-01T09:00:00Z"),
})
```

---

## See also

- [Data types](/docs/reference/python/api/values.md), All SDK data types
- [Duration](/docs/reference/python/api/values/duration.md), Duration type with unit conversion
