Find the minimum date of the three in the format DD.MM.YYYY min (D, 12/31/2017, today ()) Minimum means the earliest D - any incoming date in the format DD.MM.YYYY
2 answers
It's simple:
var now = new Date() var day1 = new Date(2018, 07, 12); var day2 = new Date(2018, 06, 12); var day3 = new Date(2018, 05, 12); if(day1 < day2 && day1 < day3){ alert(1); } else if(day2 < day3 && day2 < day1){ alert(2); } else if(day3 < day2 && day3 < day1){ alert(3); } |
I will suggest 2 ways, which is better in terms of the versatility of the date format and cross-browser can be prompted in the comments
var day1 = new Date("31.12.2017"); ... ... min=Math.min(day1,day2,day3); .parse ()
var day1 = Date.parse("31.12.2017"); ... ... min=Math.min(day1,day2,day3); |
dis any incoming, then31.12.2017is it a constant? Why compare it withtodaythen? - teran