可以定义一些包含要被moment.js忽略的字符串的自定义格式吗?
我有一个类似如下的日期字符串:
14-Apr [not valid]
我没有可能在通过moment.js之前更改日期,我想知道moment.js是否会提供一种方法来处理像这样的情况。
Moon.js正被pikaday.js库使用,同时由handsontable.js库使用 。
pikaday.js 没有回调,例如onBeforeOpen和handsontable.js也没有提供它。
It is possible to define some custom format containing a string to be ignored by moment.js ?
I have a date string like the following:
14-Apr [not valid]
I do not have the possibility of changing the date before passing it through moment.js and I'm wondering if moment.js would provide a way to deal with cases like this one.
Moment.js is being used by pikaday.js library which at the same time is being used by handsontable.js library.
pikaday.js doesn't have a callback such as onBeforeOpen and handsontable.js doesn't provide it either.
最满意答案
如文档中所述, “Moment的解析器非常宽容”,因此:
moment("14-Apr random text", "DD-MMM");将被解释为有效日期( 2016-04-14 )。
As stated in the docs "Moment's parser is very forgiving" so:
moment("14-Apr random text", "DD-MMM");will be interpreted as a valid date (2016-04-14).
更多推荐
发布评论