简体   繁体   English

momentjs:moment.js中的弃用警告错误

[英]momentjs : Deprecation warning error in moment.js

I need help I'm getting a warning on my code that has a value provided is not in a recognized ISO format. 我需要帮助,我得到的代码警告是所提供的值不是公认的ISO格式。

Here's the warning error 这是警告错误

Deprecation warning: value provided is not in a recognized ISO format. 弃用警告:提供的值不是公认的ISO格式。 moment construction falls back to js Date(), which is not reliable across all browsers and versions. 此刻的构建工作归结于js Date(),它在所有浏览器和版本之间都不可靠。 Non ISO date formats are discouraged and will be removed in an upcoming major release. 不鼓励使用非ISO日期格式,并将在即将发布的主要版本中将其删除。 Please refer to http://momentjs.com/guides/#/warnings/js-date/ for more info. 请参阅http://momentjs.com/guides/#/warnings/js-date/了解更多信息。 Arguments: [0] _isAMomentObject: true, _isUTC: true, _useUTC: true, _l: undefined, _i: 2016-9-26 19:30, _f: undefined, _strict: undefined, _locale: [object Object] 参数:[0] _isAMomentObject:true,_isUTC:true,_useUTC:true,_l:未定义,_i:2016-9-26 19:30,_f:未定义,_strict:未定义,_locale:[对象Object]

Here is my code: 这是我的代码:

var componentDetails = {
  componentName: comp.componentName,
  companyName: comp.employerdetails.companyname,
  fromDate: (comp.employmentdetails.fromdate)?moment(comp.employmentdetails.fromdate).format("DD-MM-YYYY"): comp.employmentdetails.fromdate,
  toDate: (comp.employmentdetails.todate&&comp.employmentdetails.todate!='Present')?moment(comp.employmentdetails.todate).format("DD-MM-YYYY"): comp.employmentdetails.todate,
  designation: comp.employmentdetails.designation,
  currency: comp.employmentdetails.currency,
  ctc: comp.employmentdetails.lastctc,
  period: comp.employmentdetails.period,
  senderName: req.session.loggedInUser.firstName+" "+req.session.loggedInUser.lastName,
  empCode: comp.employmentdetails.empid,
  reason: (comp.others?comp.others.reasonforleaving: "")
};

so the above part only im getting the error what can i do? 所以上面的部分只有我得到错误我该怎么办?

These values comp.employmentdetails.fromdate OR comp.employmentdetails.todate are not in ISO-8601 format. 这些值comp.employmentdetails.fromdatecomp.employmentdetails.todate都不采用ISO-8601格式。 Below are the formats: 格式如下:

An ISO 8601 string requires a date part. ISO 8601字符串需要日期部分。

2013-02-08  # A calendar date part
2013-W06-5  # A week date part
2013-039    # An ordinal date part

20130208    # Basic (short) full date
2013W065    # Basic (short) week, weekday
2013W06     # Basic (short) week only
2013050     # Basic (short) ordinal date

For more information check here 欲了解更多信息,请点击这里

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM