I’m creating a time line that is scrollable horizontally using the jQuery scrollTo plugin.
I have a calendar as an interface to select a date. When a date is selected, I would like to scroll to the closest date in the timeline.
How would I find the closest date in the timeline to the selected date?
What is the best date format to use for the calculation?
Thanks
Javascript dates have a
valueOffunction which returns the date represented as epoch, or put simply a number of milliseconds since Jan 1 1970.It is trivial to find the nearest number to a number…. its some basic difference.