使用非ISO标准日期格式的MomentJ

时间:2019-01-15 23:09:32

标签: javascript momentjs datetime-format

我有一个数据格式的数组,我需要从中添加日期到使用该数组某些格式设置的特定日期。

这是具有可能格式的数组:

        'yy-mm-dd',
        'yy-dd-mm',
        'dd-mm-yy',
        'mm-dd-yy',
        'dd-yy-mm',
        'mm-yy-dd',

我有一个函数,其参数为:fromDatemonths-要添加(30天*个月),还有一个布尔值,用于转换数组中的某些格式或仅使用标准{{ 1}}格式:

YYYY-MM-DD

}

代码知道将使用哪种格式:function calc_end_date(fromdate, months, convertFormat) { var days = 30 * months; if(convertFormat){ return moment(new Date(fromdate), custom_vars.current_date_format).add(days, 'd'); } else { return moment(fromdate).add(days, 'd').format('YYYY-MM-DD'); } } return null; 。 我现在使用的当前格式为custom_vars.current_date_format,但出现此错误:

  

未捕获的TypeError:无法读取未定义的属性'_calendar'

我已经尝试了所有方法,但对于非标准ISO格式和无效日期,我已经收到了错误或折旧警告。

0 个答案:

没有答案
相关问题