The task is to create a component that represents two date choices for setting the time interval. Without frameworks. I'm in terms of practice while noob, advise where to start at least. And where can I get the finished calendar? Or is it better to write yourself?
Closed due to the fact that the question is too common for the participants aleksandr barakin , br3t , Duck Learns to Hide , HamSter , sanmai 4 Aug '17 at 2:24 .
Please correct the question so that it describes the specific problem with sufficient detail to determine the appropriate answer. Do not ask a few questions at once. See “How to ask a good question?” For clarification. If the question can be reformulated according to the rules set out in the certificate , edit it .
1 answer
I, too, always reinvent the wheel, because I believe that the best framework is my own framework. However, the form for choosing dates is not so easy to do - here it is better to look at the finished work (just to explain for a long time) - http://amsul.ca/pickadate.js/date/ This is a very beautiful script, you can still search for js date picker .
Next, you need to convert the selected date to the timestamp for convenience. Suppose you have a form with two pickets and the following id: date1, date2.
var date1 = new Date(document.getElementById("date1").value).getTime()
Then
var date2 = new Date(document.getElementById("date2").value).getTime()
And to get range'a just Math.abs(date1 - date2) . The answer will be in milliseconds =) Divide by 1000, we get seconds.
In fact, it is difficult to explain - a lot of things, but interesting, you need to learn: Date Picker, work with forms in JS or even with elements (how to get the text / value of the html element) and read about Date in javascript.