> ## Documentation Index
> Fetch the complete documentation index at: https://docs.ahmadraza.in/llms.txt
> Use this file to discover all available pages before exploring further.

# DateTimeFormat

# Date & Time Format Directives

These directives are commonly used in tools like `date`, logging systems, and programming languages to format timestamps.

## Directives

| Directive | Represents            | Example |
| :-------- | :-------------------- | :------ |
| `%Y`      | 4-digit year          | `2026`  |
| `%m`      | Month                 | `01-12` |
| `%d`      | Day of month          | `01-31` |
| `%H`      | Hour (24-hour format) | `00-23` |
| `%M`      | Minute                | `00-59` |
| `%S`      | Second                | `00-59` |

***

## Example Format

```
%Y-%m-%d %H:%M:%S
```

Example output:

```
2026-03-06 14:25:10
```

***

## Example in Shell

```bash theme={null}
date "+%Y-%m-%d %H:%M:%S"
```

Output:

```
2026-03-06 14:25:10
```

***

## Example for File Names

```
backup-%Y-%m-%d-%H-%M-%S.sql
```

Example result:

```
backup-2026-03-06-14-25-10.sql
```

***

## Common Patterns

| Pattern             | Example               | Use          |
| ------------------- | --------------------- | ------------ |
| `%Y-%m-%d`          | `2026-03-06`          | Date only    |
| `%Y%m%d`            | `20260306`            | Compact date |
| `%Y-%m-%d %H:%M:%S` | `2026-03-06 14:25:10` | Logs         |
| `%Y%m%d-%H%M%S`     | `20260306-142510`     | Filenames    |

***
