UTC
UTC 添加了 .utc .local .isUTC API 以解析或显示 UTC。
¥UTC adds .utc .local .isUTC APIs to parse or display in UTC.
var utc = require("dayjs/plugin/utc");
// import utc from 'dayjs/plugin/utc' // ES 2015
dayjs.extend(utc);
// default local time
dayjs().format(); //2019-03-06T17:11:55+08:00
// UTC mode
dayjs.utc().format(); // 2019-03-06T09:11:55Z
// convert local time to UTC time
dayjs().utc().format(); // 2019-03-06T09:11:55Z
// While in UTC mode, all display methods will display in UTC time instead of local time.
// And all getters and setters will internally use the Date#getUTC* and Date#setUTC* methods instead of the Date#get* and Date#set* methods.
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 以当地时间解析和显示。
¥By default, Day.js parses and displays in local time.
如果要以 UTC 格式解析或显示,可以使用 dayjs.utc() 而不是 dayjs()。
¥If you want to parse or display in UTC, you can use dayjs.utc() instead of dayjs().
UTC dayjs.utc(dateType?: string | number | Date | Dayjs, format? string) 日
¥dayjs.utc dayjs.utc(dateType?: string | number | Date | Dayjs, format? string)
返回 UTC 模式下的 Dayjs 对象。
¥Returns a Dayjs object in UTC mode.
使用 UTC 时间 .utc()
¥Use UTC time .utc()
返回带有使用 UTC 时间标志的克隆 Dayjs 对象。
¥Returns a cloned Dayjs object with a flag to use UTC time.
使用当地时间 .local()
¥Use local time .local()
返回带有使用本地时间标志的克隆 Dayjs 对象。
¥Returns a cloned Dayjs object with a flag to use local time.
设置 UTC 偏移量 .utcOffset()
¥Set UTC offset .utcOffset()
返回具有新 UTC 偏移量的克隆 Dayjs 对象。
¥Returns a cloned Dayjs object with a new UTC offset.
是 UTC 模式 .isUTC()
¥isUTC mode .isUTC()
返回 boolean 指示当前 Dayjs 对象是否处于 UTC 模式。
¥Returns a boolean indicating current Dayjs object is in UTC mode or not.
