编写一个函数,将用户输入的日期格式为M/D/YYYY转换为API (YYYYMMDD)所需的格式。参数"userDate“和返回值是字符串。例如,它应该将用户输入的日期"12/31/2014“转换为适合该API的"20141231”。我试过:function formatDate(userDate) { a = new Date(userDate); m = a.getMonth(); retu
fromDateElement.value.split("/"); var timeSpread = (new Date(toArr[2],toArr[0],toArr[1]).getTime()) -
(new Date(fromArr[2],fromArr[0],fromArr[1]).getTime());