# danfo.toDateTime

danfo.**toDateTime**(data)

| Parameters | Type          | Description     | Default                                           |
| ---------- | ------------- | --------------- | ------------------------------------------------- |
| **data**   | Array, Series | **data**: Array | Series with Date strings to convert to Date time. |

## **Examples**

In the following example, we convert a **Series** of Date strings to DateTime objects, so we can call various Date methods on them.

{% tabs %}
{% tab title="Node" %}

```javascript
const dfd = require('danfojs-node')

let data = new dateRange({ "start": '1/1/2018', period: 12, freq: 'M' })
let sf = new Series(data)
sf.print()

let dt = toDateTime(data)
dt.dayOfMonth().print()
dt.dayOfWeekName().print()
dt.hours().print()
```

{% endtab %}

{% tab title="Browser" %}

```
```

{% endtab %}
{% endtabs %}

{% tabs %}
{% tab title="Output" %}

```
╔═══╤════════════════════════╗
║ 0 │ 1/1/2018, 12:00:00 AM  ║
╟───┼────────────────────────╢
║ 1 │ 2/1/2018, 12:00:00 AM  ║
╟───┼────────────────────────╢
║ 2 │ 3/1/2018, 12:00:00 AM  ║
╟───┼────────────────────────╢
║ 3 │ 4/1/2018, 12:00:00 AM  ║
╟───┼────────────────────────╢
║ 4 │ 5/1/2018, 12:00:00 AM  ║
╟───┼────────────────────────╢
║ 5 │ 6/1/2018, 12:00:00 AM  ║
╟───┼────────────────────────╢
║ 6 │ 7/1/2018, 12:00:00 AM  ║
╟───┼────────────────────────╢
║ 7 │ 8/1/2018, 12:00:00 AM  ║
╟───┼────────────────────────╢
║ 8 │ 9/1/2018, 12:00:00 AM  ║
╟───┼────────────────────────╢
║ 9 │ 10/1/2018, 12:00:00 AM ║
╚═══╧════════════════════════╝

╔═══╤═══╗
║ 0 │ 1 ║
╟───┼───╢
║ 1 │ 1 ║
╟───┼───╢
║ 2 │ 1 ║
╟───┼───╢
║ 3 │ 1 ║
╟───┼───╢
║ 4 │ 1 ║
╟───┼───╢
║ 5 │ 1 ║
╟───┼───╢
║ 6 │ 1 ║
╟───┼───╢
║ 7 │ 1 ║
╟───┼───╢
║ 8 │ 1 ║
╟───┼───╢
║ 9 │ 1 ║
╚═══╧═══╝

╔═══╤═══════════╗
║ 0 │ Monday    ║
╟───┼───────────╢
║ 1 │ Thursday  ║
╟───┼───────────╢
║ 2 │ Thursday  ║
╟───┼───────────╢
║ 3 │ Sunday    ║
╟───┼───────────╢
║ 4 │ Tuesday   ║
╟───┼───────────╢
║ 5 │ Friday    ║
╟───┼───────────╢
║ 6 │ Sunday    ║
╟───┼───────────╢
║ 7 │ Wednesday ║
╟───┼───────────╢
║ 8 │ Saturday  ║
╟───┼───────────╢
║ 9 │ Monday    ║
╚═══╧═══════════╝

╔═══╤═══╗
║ 0 │ 0 ║
╟───┼───╢
║ 1 │ 0 ║
╟───┼───╢
║ 2 │ 0 ║
╟───┼───╢
║ 3 │ 0 ║
╟───┼───╢
║ 4 │ 0 ║
╟───┼───╢
║ 5 │ 0 ║
╟───┼───╢
║ 6 │ 0 ║
╟───┼───╢
║ 7 │ 0 ║
╟───┼───╢
║ 8 │ 0 ║
╟───┼───╢
║ 9 │ 0 ║
╚═══╧═══╝
```

{% endtab %}
{% endtabs %}

{% hint style="info" %}
Date time properties of Series or datetime-like columns in DataFrame can be accessed via accessors in the **dt** name-space. See [Accessors](https://app.gitbook.com/@jsdata/s/danfojs/~/drafts/-MEMaWwva1cjt8CxnG-b/api-reference/series#accessors)
{% endhint %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://danfo.jsdata.org/api-reference/general-functions/danfo.to_datetime.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
