# UTC

URL: https://caijiao.org/dayjs/plugin/utc
Source: docs/dayjs/plugin/utc.md
Description: UTC 增加了 .utc .local .isUTC APIs 使用 UTC 模式来解析和展示时间。

UTC 增加了 `.utc` `.local` `.isUTC` APIs 使用 UTC 模式来解析和展示时间。

```javascript
var utc = require("dayjs/plugin/utc");
dayjs.extend(utc);

// 默认当地时间
dayjs().format(); //2019-03-06T17:11:55+08:00

// UTC 模式
dayjs.utc().format(); // 2019-03-06T09:11:55Z

// 将本地时间转换成 UTC 时间
dayjs().utc().format(); // 2019-03-06T09:11:55Z

// 在 UTC 模式下，所有的展示方法都将使用 UTC 而不是本地时区
// 所有的 get 和 set 方法也都会使用 Date#getUTC* 和 Date#setUTC* 而不是 Date#get* and Date#set*
dayjs.utc().isUTC(); // true
dayjs.utc().local().format(); //2019-03-06T17:11:55+08:00
dayjs.utc("2018-01-01", "YYYY-MM-DD"); // with CustomParseFormat plugin
```

默认情况下，Day.js 会把时间解析成本地时间。

Day.js 默认使用用户本地时区来解析和展示时间。 如果想要使用 UTC 模式来解析和展示时间，可以使用 `dayjs.utc()` 而不是 `dayjs()`

## dayjs.utc `dayjs.utc(dateType?: string | number | Date | Dayjs, format? string)`

返回一个使用 UTC 模式的 `Dayjs` 对象。

## Use UTC time `.utc()`

返回一个复制的包含使用 UTC 模式标记的 `Dayjs` 对象。

## Use local time `.local()`

返回一个复制的包含使用本地时区标记的 `Dayjs` 对象。

## Set UTC offset `.utcOffset()`

返回一个复制的使用 UTC 模式的 Day.js 对象。

## isUTC mode .isUTC()

返回一个 `boolean` 来展示当前 Day.js 对象是不是在 UTC 模式下。
