Search code examples
javascriptdatetimerangeslider

How can I show time in the label of jQ Range slider?


I have tried to use a plugin JQRangeslider to make a datetime filter, but the label of the filter only showed date, but not time. I checked the documentation, but it didn't tell me how to do.

And this is the documentation of jQRangeSlider

http://ghusse.github.io/jQRangeSlider/options.html


Solution

  • You can use formatter configuration option to write your format method.

    Like this

    $("#slider").dateRangeSlider({
        formatter: function(v){
        return v.toUTCString();
      },
      bounds: {min: new Date(2012, 0, 1, 10,30,10), max: new Date(2012, 11, 31, 12, 59, 59)},
        defaultValues: {min: new Date(2012, 1, 10), max: new Date(2012, 4, 22)},
        step:{days:2}
    });