UTC 偏移
获取以分钟为单位的 UTC 偏移量。
¥Get the UTC offset in minutes.
dayjs().utcOffset()
通过提供分钟来设置 UTC 偏移量并返回一个新实例。请注意,一旦你设置了偏移量,它就是固定的并且不会自行更改(即没有 DST 规则)。
¥Setting the UTC offset by supplying minutes and returns a new instance. Note that once you set an offset, it's fixed and won't change on its own (i.e there are no DST rules).
This requires the
UTC
plugin to work
dayjs.extend(utc)
dayjs().utcOffset(120)
如果输入小于 16 且大于 -16,它会将你的输入解释为小时。
¥If the input is less than 16 and greater than -16, it will interpret your input as hours instead.
// these are equivalent
dayjs().utcOffset(8) // set hours offset
dayjs().utcOffset(480) // set minutes offset (8 * 60)
将 true 传递给第二个参数将保持相同的本地时间。
¥Passing true to the second parameter will keep the same local time.
dayjs.utc('2000-01-01T06:01:02Z').utcOffset(1, true).format()
// 2000-01-01T06:01:02+01:00