如何用pickadate.js创建时间段?

时间:2015-12-22 16:04:23

标签: javascript pickadate

我想使用pickadate.js中的时间选择器创建以下下拉列表:

Between 10:00-11:00
Between 11:00-12:00
Between 12:00-13:00
Between 13:00-14:00
...

我尝试了以下内容:

$('.timepicker').pickatime({
    format: "Between HH:00-HH+1-00"
})

但是这会回来:

Between 10:00-10+1-:00
Between 11:00-11+1-:00
Between 12:00-12+1-:00
Between 13:00-13+1-:00
...

关于如何获得理想结果的任何想法?

1 个答案:

答案 0 :(得分:0)

改为使用formatLabel

$('.timepicker').pickatime({
    interval: 60,
    formatLabel: function(time) {
        var hours =  Math.floor(time.pick / 60);
        return  'Between H:i - ' + (hours+1) + ':i';
    }
});