Через документы , moment().format()
возвращает строку, поэтому ваши переменные x
и y
являются строками. Если вам нужно одновременно выполнять вычисления и отображать значения, разделите их на разные переменные:
function datecheck() {
var dateSubmitted = moment($("#input_pickup_date").val(), "L"), //your old x variable
now = moment(), //your old y variable
dateSubmittedDisplay = dateSubmitted.format("L"), //a string representing the submitted date in the format you wanted.
nowDisplay = now.format("L"); //a string representing now in the format you wanted.
console.log(x.diff(y, 'days'));
}