# Insert Date/Time

> Editor42 Insert Date/Time plugin — inserts the current date and/or time using configurable format patterns.

Source: https://editor42.com/plugins/insertdatetime  
Every page of editor42.com has a Markdown copy at its URL + `.md` (`index.md` after a URL that ends in `/`); all of them are in one file: https://editor42.com/llms-full.txt

Plugin alias: `insertdatetime`

```js
editor42.init({
  plugins: 'insertdatetime'
});
```

Inserts the current date and/or time into the editor content using configurable strftime-style format patterns (`%Y`, `%m`, `%d`, `%H`, `%M`, `%S`, etc.). Can optionally wrap the value in an HTML `<time>` element with a machine-readable `datetime` attribute.

## Options

| Option | Type | Default | Description |
|---|---|---|---|
| `insertdatetime_dateformat` | string | `%Y-%m-%d` | Default date format. |
| `insertdatetime_timeformat` | string | `%H:%M:%S` | Default time format. |
| `insertdatetime_formats` | string[] | `['%H:%M:%S', '%Y-%m-%d', '%I:%M:%S %p', '%D']` | Formats shown in the dropdown. |
| `insertdatetime_element` | boolean | `false` | Wrap inserted value in a `<time>` element. |

## Commands

| Command | Description |
|---|---|
| `editor42InsertDate` | Inserts the current date. |
| `editor42InsertTime` | Inserts the current time. |

## Toolbar buttons

| Name | Type | Description |
|---|---|---|
| `insertdatetime` | Split button | Main action uses last-selected format; dropdown shows all formats. |

## Menu items

| Name | Type | Description |
|---|---|---|
| `insertdatetime` | Nested menu item | Submenu of all formats. |
