jQuery将多个日期转换为数组

时间:2014-05-08 03:59:46

标签: jquery date

如何转换以下日期列表:

selectedDates = 
    [
      Date {Sat May 17 2014 00:00:00 GMT-0400 (Eastern Standard Time)}, 
      Date {Sat May 24 2014 00:00:00 GMT-0400 (Eastern Standard Time)}, 
      Date {Fri May 30 2014 00:00:00 GMT-0400 (Eastern Standard Time)}
    ]
上面的命运在萤火虫中显示。

成:

'05/17/2014','05/24/2014','05/30/2014'

我尝试过使用:

var newdates = $.datepicker.formatDate('mm/dd/yyyy', new Date(selectedDates));

但它只输出NaN,NaN,NaN

1 个答案:

答案 0 :(得分:0)

您可以使用$.map()

var newdates = $.map(selectedDates, function (date) {
    return $.datepicker.formatDate('mm/dd/yy', date);
})

演示:Fiddle