我以为我已经编写了代码来计算两个给定日期之间的持续时间。
但是我的计算结果不正确。
以下示例计算额外的一年......
请帮忙....
var fromdate = "03/10".split("/");
var todate = "01/14".split("/");
var months = todate[0] - fromdate[0] + 12 * (todate[1] - fromdate[1]);
var duration = Math.round(months / 12) + " years " + (months % 12) + " months";
console.log(duration)
答案 0 :(得分:0)
使用地板而不是圆形:
var duration = Math.round(months / 12) + " years " + (months % 12) + " months";
^---// Change to Math.floor
答案 1 :(得分:0)
您应该使用Date object
org.apache.solr.common.SolrException:org.apache.solr.common.SolrException: Unknown FieldType: 'string' used in QueryElevationComponent