Moment.js 技术指南

指南区域旨在帮助开发者学习如何更好地与日期和时间问题域以及 Moment.js 库进行交互。我们在这里处理我们最常见的支持请求,因此这是一个检查你可能遇到的任何问题的解决方案的好地方。

¥The guides area is designed to help developers learn to better interact with the date and time problem domain, and the Moment.js library. We address our most frequently seen support requests here, so it is a great place to check for solutions to any issues you may have.

指南部分是新建的,仍在建设中。如果你有想要在此处查看的指南的请求,或者想要添加指南,请在 momentjs.com 存储库 中创建问题或提出拉取请求。

¥The guides section is new and still under construction. If you have a request for a guide that you would like to see here, or would like to add a guide please create an issue or make a pull request in the momentjs.com repository.

如果你刚刚开始,请查看此 scrimba moment 指南

¥Check out this scrimba moment guide if you're just starting.

可变性 1.0.0+

Moment.js 中的 moment 对象是可变的。这意味着诸如加、减或设置之类的操作会更改原始 moment 对象。当第一次使用 Moment.js 时,许多开发者对这样的场景感到困惑:

¥The moment object in Moment.js is mutable. This means that operations like add, subtract, or set change the original moment object. When first using Moment.js many developers are confused by scenarios like this:

var a = moment('2016-01-01'); 
var b = a.add(1, 'week'); 
a.format();
"2016-01-08T00:00:00-06:00"

如你所见,添加一周修改的 a。为避免出现这种情况,请在执行日期算术运算之前克隆 moment:

¥As you can see, adding one week mutated a. To avoid situations like that, clone the moment before performing date math:

var a = moment('2016-01-01'); 
var b = a.clone().add(1, 'week'); 
a.format();
"2016-01-01T00:00:00-06:00"

日期算术与时间算术

时间算术和日期算术之间存在逻辑差异。

¥There is a logical difference between time math and date math.

在 Moment.js 中,时间算术假定线性时间尺度,只是根据提供的时间单位的数量递增或递减基于 UTC 的时间戳。

¥In Moment.js time math assumes a linear time scale, just incrementing or decrementing the UTC-based timestamp by the amount of the time units provided.

日期算术不使用线性时间尺度,而是增加或减少日历上的日期。这是因为一天、一个月或一年中的时间量是可变的。例如,由于夏令时转换,一天的长度可能在 23 到 25 小时之间。当然,月份的天数会有所不同,并且由于闰年,年份的长度也会有所不同。日期算术会导致一些有趣的场景。

¥Date math does not use a linear time scale, but rather increments or decrements the dates on the calendar. This is because the amount of time in a day, month, or year is variable. For example, due to daylight saving time transition, a day may be anywhere between 23 and 25 hours long. Months of course vary in number of days, and due to leap year, years vary in length as well. Date math can cause some interesting scenarios.

由于夏令时,一天可能不等于 24 小时:

¥Due to daylight saving time, one day may not equal 24 hours:

//date math
moment('2016-03-12 13:00:00').add(1, 'day').format('LLL')
"March 13, 2016 1:00 PM"
//time math
moment('2016-03-12 13:00:00').add(24, 'hours').format('LLL')
"March 13, 2016 2:00 PM"

由于闰年,一年可能不等于 365 天:

¥Due to leap years, one year may not equal 365 days:

moment('2016-01-01').add(1, 'year').format('LL')
"January 1, 2017"
moment('2016-01-01').add(365, 'day').format('LL')
"December 31, 2016"

由于天算术中持续时间的可变性,Moment 的 API 不正式支持天数和更大天数的加减小数值。Moment.js 将接受小数值并通过四舍五入到最接近的整数来尽力处理它们。

¥Because of the variability of duration in day math, Moment's API does not officially support adding or subtracting decimal values for days and larger. Moment.js will accept decimal values and do its best to handle them by rounding to the nearest whole number.

从 2.12.0 开始,小数日和月值使用绝对值/舍入转换为整数。这意味着 1.5 舍入为 2,-1.5 舍入为 -2。

¥As of 2.12.0 decimal day and month values use absolute value/round to convert to integers. This means that 1.5 rounds to 2, and -1.5 rounds to -2.

moment().add(1.5, 'days') == moment().add(2, 'days')
moment().add(-1.5, 'days') == moment().add(-2, 'days') == moment().subtract(1.5, 'days') == moment().subtract(2, 'days')
moment().add(2.3, 'months') == moment().add(2, 'months')
moment().add(-2.3, 'months') == moment().add(-2, 'months') == moment().subtract(2.3, 'months') == moment().subtract(2, 'months')

季度和年份转换为月份,然后绝对值/四舍五入。

¥Quarters and years are converted to months, and then absolute value/rounded.

moment().add(1.5, 'years') == moment().add(18, 'months')
moment().add(.8, 'years') == moment().add(9.6, 'months') == moment().add(10, 'months')
moment().add(1.5, 'quarters') == moment().add(4.5, 'months') == moment().add(5, 'months')

时区与偏移量

通常,人们对时区和 UTC 偏移量之间的差异感到困惑。

¥Frequently, people are confused about the difference between time zones and UTC offsets.

UTC 偏移量是表示特定日期和时间距 UTC 多远的值。大多数时候它以 HH:mm 的格式表示。

¥A UTC offset is a value that represents how far a particular date and time is from UTC. It is expressed in the format HH:mm most of the time.

时区是所有人遵守法定标准时间的地理区域。

¥A time zone is a geographical region where all people observe a legally mandated standard time.

由于夏令时,一个时区通常与 UTC 有多个偏移量。多个时区在一年中的某个时间点可能具有相同的偏移量。例如,美洲/芝加哥、美洲/丹佛和美洲/伯利兹时区在不同时间都有 -06:00 的偏移量。因此,不可能仅从偏移值推断出时区。

¥A time zone usually has more than one offset from UTC due to daylight saving time. Several time zones may have the same offset at some point during the year. For example, the time zones America/Chicago, America/Denver, and America/Belize all have an offset of -06:00 at varying times. For this reason, it is impossible to infer a time zone from just an offset value.

Moment.js 核心库提供与基于偏移值调整时间相关的功能。它不支持根据时区数据调整日期 - 这是由 Moment TimeZone 库提供的。

¥The Moment.js core library provides functionality related to adjusting times based on an offset value. It does not provide support for adjusting dates based on time zone data - this is provided by the Moment TimeZone library.

有关此问题的深入描述,请参阅 Stack Overflow 标签。

¥For an in depth description of this issue, see the Stack Overflow tag.

JavaScript 日期

Moment.js 为原生 JavaScript 日期对象提供了一个封装器。在这样做时,Moment.js 扩展了功能并解决了对象中的几个缺陷。

¥Moment.js provides a wrapper for the native JavaScript date object. In doing this, Moment.js extends the functionality and also accounts for several deficiencies in the object.

使用原生日期进行解析尤其不可预测。例如,假设我在美国使用一台计算机,但我有一个 DD/MM/YYYY 格式的日期。

¥Parsing is notably unpredictable with native date. For instance, suppose I am using a computer in the United States, but I have a date in DD/MM/YYYY format.

var a = new Date('01/12/2016'); //December 1 2016 in DD/MM/YYYY format
//"Tue Jan 12 2016 00:00:00 GMT-0600 (Central Standard Time)"

对于原生 Date 对象的这种行为没有好的解决方法。Moment 的解析器处理得很好:

¥There is no good work-around for this behavior with the native Date object. Moment's parser handles it just fine though:

moment('01/12/2016', 'DD/MM/YYYY', true).format()
"2016-12-01T00:00:00-06:00"

此外,ECMA Script 5 规范对 ISO 8601 日期的偏移量做出了不寻常的断言:

¥In addition, the ECMA Script 5 Specification makes an unusual assertion about the offset of ISO 8601 dates:

缺少时区偏移量的值为 "Z"

¥The value of an absent time zone offset is "Z"

实际上,这意味着没有偏移量的 ISO 8601 日期将被视为 UTC 值,从而产生以下奇怪现象:

¥Effectively what this means is that ISO 8601 dates without an offset are to be treated as UTC values, creating the following oddity:

//US local format
var a = new Date('1/1/2016'); 
//"Fri Jan 01 2016 00:00:00 GMT-0600 (Central Standard Time)"

//ISO 8601
var a = new Date('2016-01-01');
//"Thu Dec 31 2015 18:00:00 GMT-0600 (Central Standard Time)"

ES2015 规范修复了这个错误,使其与 ISO8601 规范保持一致,后者指定本地时间不存在偏移量。这本身就很糟糕,因为它具有许多负面的向后兼容性影响。

¥The ES2015 spec fixes this mistake, bringing it in line with the ISO8601 specification, which specifies local time absent of offset. This is in it's own way bad as it has numerous negative back compatibility implications.

对于 Moment,日期始终被解释为本地时间,除非你另有说明。这不会随着 ES2015 的采用而改变。

¥With Moment, the date is always interpreted as local time, unless you specify otherwise. This is not something that will change with the adoption of ES2015.

moment('2016-01-01')
//"2016-01-01T00:00:00-06:00"

算术是另一个缺少原生 Date 对象的字段。Date 对象实际上没有为此提供 API。相反,它依赖于溢出的日期值。假设你想将 2016 年 4 月 30 日增加 1 天。使用日期对象,你可以执行以下操作:

¥Arithmetic is another area where the native Date object is lacking. The Date object actually provides no API for this. Instead, it relies on overflowing date values. Suppose you wanted to add 1 day to April 30, 2016. With the date object you would do the following:

var a = new Date('4/30/2016'); 
a.setDate(a.getDate() + 1);

这可以解决问题,但有点不直观。Moment 提供了一个 API 来添加/减去:

¥This does the trick, but is somewhat unintuitive. Moment provides an API to add/subtract:

moment('4/30/2016', 'MM/DD/YYYY').add(1, 'day')
//"2016-05-01T00:00:00-05:00"

内部属性

Moment 对象有几个以 _ 为前缀的内部属性。

¥Moment objects have several internal properties that are prefixed with _.

最常查看的内部属性是 _d 属性,它保存 Moment 封装器的 JavaScript 日期。开发者经常对 _d 值的控制台输出感到困惑。Moment 使用一种称为纪元偏移的技术,导致此属性有时与 Moment 反映的实际日期值不同。特别是,如果使用 Moment TimeZone,则此属性几乎永远不会与 Moment 从其公共 .format() 函数输出的实际值相同。因此,_d 的值和任何其他以 _ 为前缀的属性不应用于任何目的。

¥The most commonly viewed internal property is the _d property that holds the JavaScript Date that Moment wrappers. Frequently, developers are confused by console output of the value of _d. Moment uses a technique called epoch shifting that causes this property to sometimes differ from the actual date value that the Moment reflects. In particular if Moment TimeZone is in use, this property will almost never be the same as the actual value that Moment will output from its public .format() function. As such, the values of _d and any other properties prefixed with _ should not be used for any purpose.

要打印出 Moment 的值,请使用 .format().toString().toISOString()

¥To print out the value of a Moment, use .format(), .toString() or .toISOString().

要从 Moment 检索原生 Date 对象,请使用 .toDate()。此函数返回一个正确移动的日期以与第三方 API 交互。

¥To retrieve a native Date object from Moment, use .toDate(). This function returns a properly shifted date for interaction with third party APIs.

Moment.js 有一个非常灵活和高级的解析器,可以提供范围广泛的功能。解析器的灵活性也使其成为 Moment.js 最常被误用的工具之一。

¥Moment.js has a very flexible and advanced parser that allows a huge range of functionality.\ The flexibility of the parser also makes it one of the most frequently misused tools of Moment.js.

本节列出了有关如何在你的情况下正确使用解析器的一些指南。

¥This section lays out some guidelines about how to correctly use the parser in your situation.

本地 vs UTC vs 偏移量

Moment 提供了三个用于解析日期的函数,基本的 moment 函数、moment.utc 和 moment.parseZone。

¥Moment offers three functions for parsing dates, the basic moment function, moment.utc, and moment.parseZone.

如果你希望在用户本地时间的上下文中与日期交互,请使用 moment 函数。

¥If you wish to interact with a date in the context of the user's local time, use the moment function.

moment('2016-01-01T23:35:01');

这会产生一个与本地计算机具有相同 UTC 偏移量的日期:

¥This results in a date with a UTC offset that is the same as the local computer:

"2016-01-01T23:35:01-06:00"

如果你希望将日期作为 UTC 日期进行交互,请使用 moment.utc:

¥If you wish to interact with the date as a UTC date, use moment.utc:

moment.utc('2016-01-01T23:35:01');

这会产生 utc 偏移量为 +0:00 的日期:

¥This results in a date with a utc offset of +0:00:

"2016-01-01T23:35:01+00:00"

如果你的日期格式具有固定的时区偏移量,请使用 moment.parseZone:

¥If your date format has a fixed timezone offset, use moment.parseZone:

moment.parseZone("2013-01-01T00:00:00-13:00");

这会产生一个具有固定偏移量的日期:

¥This results in a date with a fixed offset:

"2013-01-01T00:00:00-13:00"

请注意,如果你使用 moment() 或 moment.utc() 来解析具有指定偏移量的日期,则日期将从该偏移量转换为本地或 UTC:

¥Note that if you use moment() or moment.utc() to parse a date with a specified offset, the date will be converted from that offset to either local or UTC:

此日期偏移 8 小时,从 +2 移动到 -6(本地机器的偏移量)

¥This date is shifted by 8 hours, moving from +2 to -6 (the offset of the local machine)

moment('2016-01-01T00:00:00+02:00').format()
"2015-12-31T16:00:00-06:00"

此日期偏移 2 小时,从 +2 变为 UTC

¥This date is shifted by 2 hours, moving from +2 to UTC

moment.utc('2016-01-01T00:00:00+02:00').format()
"2015-12-31T22:00:00+00:00"

已知的日期格式

如果你知道要解析的日期字符串的格式,那么明确指定该格式始终是最佳选择。

¥If you know the format of the date string that you will be parsing, it is always the best choice to explicitly specify that format.

示例:

¥Examples:

moment('01/01/2016', 'MM/DD/YYYY')
moment('2016-01-01 11:31:23 PM', 'YYYY-MM-DD hh:mm:ss a')

如果你的日期采用 ISO 8601 格式,则可以使用 moment 中内置的常量来指示:

¥If your dates are in an ISO 8601 format, you can use a constant built into moment to indicate that:

moment('2016-01-01 12:25:32', moment.ISO_8601)

ISO 8601 格式包括但不限于:

¥ISO 8601 formats include, but are not limited to:

2013-02-08               # A calendar date part
2013-W06-5               # A week date part
2013-02-08T09            # An hour time part separated by a T
2013-02-08 09            # An hour time part separated by a space
2013-02-08 09:30:26      # An hour, minute, and second time part
2013-02-08 09+07:00      # +-HH:mm

有关完整列表,请参阅有关解析字符串的 API 文档。

¥ See the API documentation on parsing strings for a full listing.

严格模式

严格模式是解析日期的推荐模式。如果你的代码库允许,你应该始终使用严格模式。在 GitHub 和 Stack Overflow 上看到的一半以上的解析器问题可以通过严格模式修复。

¥Strict mode is the recommended mode for parsing dates. You should always use strict mode if your code base will allow it. More than half of the parser issues seen on GitHub and Stack Overflow can be fixed by strict mode.

在以后的版本中,解析器将默认使用严格模式。

¥In a later release, the parser will default to using strict mode.

严格模式要求 moment 的输入与指定的格式完全匹配,包括分隔符。通过将 true 作为第三个参数传递给 moment 函数来设置严格模式。

¥Strict mode requires the input to the moment to exactly match the specified format, including separators. Strict mode is set by passing true as the third parameter to the moment function.

moment('01/01/2016', 'MM/DD/YYYY', true).format()
"2016-01-01T00:00:00-06:00"
moment('01/01/2016 some text', 'MM/DD/YYYY', true).format()
"Invalid date"

分隔符匹配:

¥Separator matching:

//forgiving mode
moment('01-01-2016', 'MM/DD/YYYY', false).format()
"2016-01-01T00:00:00-06:00"
//strict mode
moment('01-01-2016', 'MM/DD/YYYY', true).format()
"Invalid date"

严格模式修复的场景:

¥Scenarios fixed by strict mode:

//UUID matches YYYYDDD because it starts with 7 digits
moment('5917238b-33ff-f849-cd63-80f4c9b37d0c', moment.ISO_8601).format()
"5917-08-26T00:00:00-05:00"
//strict mode fails because trailing data exists
moment('5917238b-33ff-f849-cd63-80f4c9b37d0c', moment.ISO_8601, true).format()
"Invalid date"
//date has out of range value but is parsed anyways
moment('100110/09/2015', 'MM/DD/YYYY').format()
"2015-10-09T00:00:00-05:00"
//strict mode catches out of range issue
moment('100110/09/2015', 'MM/DD/YYYY', true).format()
"Invalid date"
//wrong date is parsed because non-strict mode ignores data after format
moment('2016-12-31 11:32 PM').format('LT')
"11:32 AM"
//trailing data is noticed
moment('2016-12-31 11:32 PM', moment.ISO_8601, true).format('LT')
"Invalid date"

宽容模式

虽然严格模式在大多数情况下效果更好,但当传递给 moment 的字符串格式可能不同时,宽容模式可能非常有用。

¥While strict mode works better in most situations, forgiving mode can be very useful when the format of the string being passed to moment may vary.

宽容模式有用的常见场景是第三方 API 提供日期,并且该 API 的日期格式可能会更改。假设一个 API 以 'YYYY-MM-DD' 格式发送日期,然后更改为 'MM/DD/YYYY' 格式。

¥A common scenario where forgiving mode is useful is in situations where a third party API is providing the date, and the date format for that API could change. Suppose that an API starts by sending dates in 'YYYY-MM-DD' format, and then later changes to 'MM/DD/YYYY' format.

在严格模式下,以下代码会导致显示 '无效日期':

¥In strict mode, the following code results in 'Invalid Date' being displayed:

moment('01/12/2016', 'YYYY-MM-DD', true).format()
"Invalid date"

在使用格式字符串的宽容模式下,你会得到一个错误的日期:

¥In forgiving mode using a format string, you get a wrong date:

moment('01/12/2016', 'YYYY-MM-DD').format()
"2001-12-20T00:00:00-06:00"

宽容模式下的错误日期场景对用户来说当然不太明显,但由于这个原因可能会在很长一段时间内被忽视。

¥The wrong date scenario in forgiving mode is certainly less obvious to the user, but by that token could go unnoticed for a long time.

在严格模式和宽容模式之间进行选择时,重要的是要考虑是日期准确更重要,还是日期从不显示为 "无效日期"。

¥When choosing between strict and forgiving mode, it is important to consider whether it is more important that dates be accurate, or that dates never display as "Invalid Date".

多种格式

Moment 的解析器支持为日期字符串指定多种可能的格式。这对于日期可能来自多个数据源的情况非常有用。只需将格式作为数组传递:

¥Moment's parser supports specifying multiple possible formats for a date string. This can be extremely useful for situations where a date may be coming from multiple data sources. Just pass the formats as an array:

moment('12 March, 2016', ['DDMMMMY', 'MMMMDDY']).format()
"2016-03-12T00:00:00-06:00"
moment('March 12, 2016', ['DDMMMMY', 'MMMMDDY']).format()
"2016-03-12T00:00:00-06:00"

为了使此功能正常工作,moment 必须解析提供的每种格式。因此,使用的格式越多,解析所需的时间就越长。Moment 用于确定使用哪种格式的启发式方法如下:

¥In order for this functionality to work properly, moment must parse every format provided. Because of this, the more formats that are used, the longer that parsing takes. Moment's heuristic for determining which format to use is as follows:

  • 比无效日期更喜欢产生 有效 日期的格式。

    ¥Prefer formats resulting in valid dates over invalid ones.

  • 更喜欢解析更多字符串的格式而不是更少,使用更多格式而不是更少的格式,即更喜欢更严格的解析。

    ¥Prefer formats that parse more of the string than less and use more of the format than less, i.e. prefer stricter parsing.

  • 优先使用数组中较早的格式而不是较晚的格式。

    ¥Prefer formats earlier in the array than later.

Moment.js 有几个地方显示有关将来将被删除的功能的弃用警告。此处概述了解决方法。

¥There are several places where Moment.js displays deprecation warnings about functionality that will be removed in the future. Work-arounds are outlined here.

JS 日期构造

Moment construction falls back to js Date. 
This is discouraged and will be removed in an upcoming major release.

当没有找到传递给字符串构造函数的日期的已知格式时,将抛出此弃用警告。要解决此问题,请指定传递给 moment() 的字符串的格式。

¥This deprecation warning is thrown when no known format is found for a date passed into the string constructor. To work around this issue, specify a format for the string being passed to moment().

有关更多信息,请参阅解析文档。

¥See the parsing docs for more information.

查看原始 GitHub 问题

¥View original GitHub issue

定义语言环境覆盖

Use moment.updateLocale(localeName, config) to change an existing locale. 
moment.defineLocale(localeName, config) should only be used for creating a new locale

当你尝试使用 defineLocale 函数更改现有语言环境时,会抛出此弃用警告。这样做会导致与属性继承相关的意外行为。moment.updateLocale 将正确替换现有语言环境的属性。

¥This deprecation warning is thrown when you attempt to change an existing locale using the defineLocale function. Doing this will result in unexpected behavior related to property inheritance. moment.updateLocale will properly replace properties on an existing locale.

查看原始拉取请求

¥View original pull request

父语言环境未定义

自 2.16.0 起已删除警告。

¥Warning removed since 2.16.0.

可以在定义或加载父对象本身之前用父对象定义语言环境。如果在创建 moment 时父级不存在或无法延迟加载,则父级将默认为全局语言环境。

¥A locale can be defined with a parent before the parent itself is defined or loaded. If the parent doesn't exist or can't be lazy loaded when the moment is created, the parent will default to the global locale.

找不到语言环境

Locale <key> not found. Did you forget to load it?

当设置了全局语言环境但 Moment 找不到它时,会显示此警告。也许这个语言环境没有打包在你的副本中。

¥This warning is displayed when a global locale is set but Moment cannot find it. Perhaps this locale is not bundled in your copy.

加法/减法

moment().add(period, number) is deprecated. Please use moment().add(number, period)
moment().subtract(period, number) is deprecated. Please use moment().subtract(number, period)

Moment 不推荐将加减参数排序为 (period, number)。反转你的参数。

¥Moment deprecated ordering the parameters of add and subtract as (period, number). Invert your parameters.

不好的:

¥Bad:

moment().add('hours', 3);

好的:

¥Good:

moment().add(3, 'hours');

最小/最大

moment().min is deprecated, use moment.max
moment().max is deprecated, use moment.min

这个警告不是拼写错误,但它令人困惑。

¥This warning is not a typo, but it is confusing.

在 2.7.0 版本之前,moment 支持 moment().min 和 moment().max 函数。这些函数不直观。

¥Previous to version 2.7.0, moment supported moment().min and moment().max functions. These functions were unintuitive.

Min 将返回所讨论的两个 moment 中较大的一个,而 max 将返回较小的一个。

¥Min would return the greater of the two moments in question, and max would return the lesser.

由于这种反向行为,弃用警告中提供的建议是正确的。

¥Due to this inverted behavior, the suggestion provided in the deprecation warning is correct.

moment('2016-01-01').min('2016-02-01').format()
"2016-02-01T00:00:00-06:00"
//is equivalent to
moment.max(moment('2016-01-01'), moment('2016-02-01')).format()
"2016-02-01T00:00:00-06:00"
moment('2016-01-01').max('2016-02-01').format()
"2016-01-01T00:00:00-06:00"
//is equivalent to
moment.min(moment('2016-01-01'), moment('2016-02-01')).format()
"2016-01-01T00:00:00-06:00"

请参阅原始 GitHub 问题。

¥See original GitHub issue.

时区

moment().zone is deprecated, 
use moment().utcOffset instead.

此弃用是为了清楚起见。

¥This deprecation was made for purposes of clarity.

moment().zone() 的结果是一个整数,指示给定 moment 相对 UTC 偏移的分钟数,符号反转(美国时间结果为正值)。

¥The result of moment().zone() is an integer that indicates the number of minutes that a given moment is offset from UTC, with the sign inverted (US moments result in a positive value).

使用 moment().zone(number) 设置偏移量将设置日期的偏移量,同样使用倒号。

¥Using moment().zone(number) to set the offset will set the offset on the date, also using an inverted sign.

因为时区与偏移量不同,所以名称更改为 utcOffset。那时符号被更正以反映 UTC 偏移的实际方向。

¥Because a time zone is not the same thing as an offset, the name was changed to utcOffset. At that time the sign was corrected to reflect the actual direction of the UTC offset.

moment().zone()
360
//is replaced by
moment().utcOffset()
-360

moment().zone(420)
//is replaced by 
moment().utcOffset(-420)

有关时区与偏移量的更多信息,请参阅时区与偏移量指南。

¥For more information on time zone vs offset, see the Time Zone vs Offset guide.

查看原始 GitHub 问题。

¥View original GitHub issue.

这些资源由日期/时间/时区社区的成员制作。

¥These resources are made by members of the date/time/time zone community.

博客

马特·约翰逊的博客

¥Matt Johnson's Blog

  • Moment.js 核心贡献者。编程中的日期和时间概念。

    ¥Moment.js core contributor. Date and time concepts in programming.

玛吉品特的博客

¥Maggie Pint's Blog

  • Moment.js 核心贡献者。Moment.js 开发进度和蓝图。Moment.js 库帮助。

    ¥Moment.js core contributor. Moment.js development progress and roadmaps. Moment.js library help.

劳·塔恩斯科夫的博客

¥Lau Taarnskov's blog

  • 作者 - Elixir 日历。日期和时间编程概念。Elixir 日期和时间。

    ¥Author - Elixir Calendar. Date and time programming concepts. Elixir date and time.

乔恩·斯基特的博客

¥Jon Skeet's blog

  • 作者 - 野田时间。Stack Overflow #1 用户。日期和时间编程概念。

    ¥Author - NodaTime. Stack Overflow #1 user. Date and time programming concepts.