Is it possible to check whether an end date is greater than or equal to a start date in Javascript? My dates are strings in the format 'dd/mm/yyyy'.
标签:
javascript
相关问题
- Is there a limit to how many levels you can nest i
- How to toggle on Order in ReactJS
- void before promise syntax
- Keeping track of variable instances
- Can php detect if javascript is on or not?
This will work for Leap years also..in dd/mm/yyyy format(not any other format).
First use this function will convert string to Date type in js:
Second: after you get the javascript date type, you just compare it as normal type like date1 > date2 or date1 == date2.
Or use this function to get the difference date between date:
Follow this link is a simple demo to get difference days between dates. Link demo here
Took me some time to find, but JQuery implements this exact functionality with
DatePicker
date-range
. (Source code available in link as well.)Moment.js also handles date comparisons very well using the diff function.
Most simple way to do this.