# CustomParseFormat

URL: https://caijiao.org/dayjs/plugin/custom-parse-format
Source: docs/dayjs/plugin/custom-parse-format.md
Description: CustomParseFormat 插件扩展了 dayjs()，支持自定义时间格式解析，包括严格解析模式。适用于多语言和不同时间格式的场景。

CustomParseFormat 拓展了 `dayjs()` 支持自定义时间格式.

```javascript
var customParseFormat = require("dayjs/plugin/customParseFormat");
dayjs.extend(customParseFormat);

dayjs("05/02/69 1:02:03 PM -05:00", "MM/DD/YY H:mm:ss A Z");
// Returns an instance containing '1969-05-02T18:02:03.000Z'

dayjs("2018 Enero 15", "YYYY MMMM DD", "es");
// Returns an instance containing '2018-01-15T00:00:00.000Z'

dayjs("1970-00-00", "YYYY-MM-DD", true); // strict parsing
```

## 支持的解析占位符列表

| 输入   | 例子             | 详情                    |
| ------ | ---------------- | ----------------------- |
| `YY`   | 01               | 两位数的年份            |
| `YYYY` | 2001             | 四位数的年份            |
| `M`    | 1-12             | 月份，从 1 开始         |
| `MM`   | 01-12            | 月份，两位数            |
| `MMM`  | Jan-Dec          | 缩写的月份名称          |
| `MMMM` | January-December | 完整的月份名称          |
| `D`    | 1-31             | 月份里的一天            |
| `DD`   | 01-31            | 月份里的一天，两位数    |
| `H`    | 0-23             | 小时                    |
| `HH`   | 00-23            | 小时，两位数            |
| `h`    | 1-12             | 小时, 12 小时制         |
| `hh`   | 01-12            | 小时, 12 小时制, 两位数 |
| `m`    | 0-59             | 分钟                    |
| `mm`   | 00-59            | 分钟，两位数            |
| `s`    | 0-59             | 秒                      |
| `ss`   | 00-59            | 秒 两位数               |
| `S`    | 0-9              | 毫秒，一位数            |
| `SS`   | 00-99            | 毫秒，两位数            |
| `SSS`  | 000-999          | 毫秒，三位数            |
| `Z`    | -05:00           | UTC 的偏移量            |
| `ZZ`   | -0500            | UTC 的偏移量，两位数    |
| `A`    | AM PM            | 上午 下午 大写          |
| `a`    | am pm            | 上午 下午 小写          |
| `Do`   | 1st... 31st      | 带序数词的月份里的一天  |
| `X`    | 1410715640.579   | Unix 时间戳             |
| `x`    | 1410715640579    | Unix 时间戳             |
