与 chrome 相比,Momentjs 在 Firefox 上返回不同的结果
Momentjs returning different results on firefox compared to chrome
只需在 firefox 上输入这一行,chrome
moment("September 2015") < moment("September 2015").endOf('month')
我在 chrome 上得到 true 而在 firefox 上得到 false,我怎样才能使结果更一致?
来自 momentjs 文档 http://momentjs.com/docs/#/parsing/now/
Browser support for parsing strings is inconsistent. Because there is
no specification on which formats should be supported, what works in
some browsers will not work in other browsers. For consistent results
parsing anything other than ISO 8601 strings, you should use String +
Format.
所以你可以指定像
这样的格式
moment("September 2015", "MMMM YYYY") < moment("September 2015", "MMMM YYYY").endOf('month')
它应该可以正常工作。
只需在 firefox 上输入这一行,chrome
moment("September 2015") < moment("September 2015").endOf('month')
我在 chrome 上得到 true 而在 firefox 上得到 false,我怎样才能使结果更一致?
来自 momentjs 文档 http://momentjs.com/docs/#/parsing/now/
Browser support for parsing strings is inconsistent. Because there is no specification on which formats should be supported, what works in some browsers will not work in other browsers. For consistent results parsing anything other than ISO 8601 strings, you should use String + Format.
所以你可以指定像
这样的格式moment("September 2015", "MMMM YYYY") < moment("September 2015", "MMMM YYYY").endOf('month')
它应该可以正常工作。