当用户更改值时从 ION 滑块获取日期值

getting date value from ION slider with moment when user changes the value

我有一个关于我的编程问题的问题,我正在使用 ION Slider (http://ionden.com/a/plugins/ion.rangeSlider/demo_advanced.html) 和 Moment.js 进行日期范围操作。我需要为我的程序设置特定的日期范围和特定的日期范围选择器。

每当用户更改值时,它都应该更新数据库。但是我在这里遇到了一个小问题,滑块在 console.log() 中没有显示正确的格式。请帮我解决这种情况。我的代码是,

var startDate = moment("2014-01-05");
    var endDate = moment("2014-01-13");

    range.ionRangeSlider({
        type: "double",
        grid: true,

        min: +moment(startDate).format("X"),
        max: +moment(endDate).format("X"),

        from: +moment(endDate).subtract(5, "days").format("X"),
        to: +moment(endDate).subtract(2, "days").format("X"),

        prettify: function (num) {
            return moment(num, "X").format("dddd, MMM Do YYYY");
        }
    });

    range.on("change", function () {
    var $this = $(this),
        from = $this.data("from"),
        to = $this.data("to");

        console.log(from + " - " + to);
    });

控制台日志,

1389113336 - 1389373200
jquery-... > eval (line 28)
1389111677 - 1389373200
jquery-... > eval (line 28)
1389111345 - 1389373200
jquery-... > eval (line 28)
1389109686 - 1389373200
jquery-... > eval (line 28)
1389108359 - 1389373200
jquery-... > eval (line 28)
1389106368 - 1389373200
jquery-... > eval (line 28)
1389103713 - 1389373200
jquery-... > eval (line 28)
1389102054 - 1389373200

它应该在控制台日志中显示日期。

我自己找到了答案,

var startDate = moment("2014-01-01");
    var endDate = moment("2014-01-30");

    range.ionRangeSlider({
        type: "double",
        grid: true,
        force_edges: true,

        min: +moment(startDate).format("X"),
        max: +moment(endDate).format("X"),

        from: +moment(endDate).subtract(5, "days").format("X"),
        to: +moment(endDate).subtract(2, "days").format("X"),

        prettify: function (num) {
            return moment(num, "X").format("dddd, MMM Do YYYY");
        }
    });


    range.on("change", function () {
            var $this = $(this), 
                from = $this.data("from"),
                to = $this.data("to");
                console.log( moment(from,"X").format("dddd, MMM Do YYYY") + " - " + moment(to,"X").format("dddd, MMM Do YYYY"))
        });

    });