I've been trying to add this slider: http://ionden.com/a/plugins/ion.rangeSlider/demo_advanced.html
This is my sample code:
$("#range").ionRangeSlider({
min: +moment().subtract(12, "hours").format("X"), //need to change to 00:00
max: +moment().format("X"), //need to change this to 23:59
from: +moment().subtract(6, "hours").format("X"),
grid: true,
force_edges: true,
prettify: function (num) {
var m = moment(num, "X").locale("en");
return m.format("HH:mm");
}
});
I would like to add min to 00:00 and max to 23:59
I tried doing
moment("1234", "hmm").format("HH:mm")
I'm getting either invalid date or NaN.
Please help me. I'm not sure where I'm going wrong.
MomentJs recently announced that the library is now deprecated. This is a big deal for the javascript community who actively downloads moment almost 15 million times a week. With that I began a journey during a Hackathon to replace moment in a core library at my company.
Compare two dates using Moment. js has a diff() method, which gives the difference between two dates in years, months, days, hours, minutes, seconds, milliseconds, etc. We can use the second unit in our case to find the difference between the two dates.
You can directly call function momentInstance. valueOf(), it will return numeric value of time similar to date. getTime() in native java script.
year() method is used to get or set the year of the Moment object. The year value that can be set has a range from -270,000 to 270,000. Syntax: moment().
A moment object is a datetime, you cannot just add a time only. Instead create the object and change the time:
min: +moment().startOf("day").format("X"),
max: +moment().endOf("day").format("X"),
Then the prettify
callback will only show the time in the slider.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With