import { Meta } from '@storybook/addon-docs/blocks'

<Meta title='@dxtmisha/en/functional-basic/Functions/toDate - Converting a value to a Date object'/>

# `toDate`

Converts the input value (date, number, or string) into a `Date` object. Supports various string formats, including ISO-like strings without delimiters, as well as automatic timezone substitution.

**Parameters:**
- `value?: T` — The input value (a `Date` object, timestamp in milliseconds, or a date string).

**Returns:**
`Date` — The resulting date object. If the value is not provided or is `null`, the current date is returned.

```typescript
import { toDate } from '@dxtmisha/functional-basic'

console.log(toDate('20231027')) // '2023-10-27T00:00:00.000Z'
console.log(toDate(1672531200000)) // '2023-01-01T00:00:00.000Z'
console.log(toDate('12:00')) // '2000-01-01T12:00:00.000Z'
```
