Showing posts with label date checking between two dates. Show all posts
Showing posts with label date checking between two dates. Show all posts

Check current date falls between two dates function in jquery

         The function is to check date comes between start and end date which should be in "dd/mm/yyyy" format.

function dateCheck(dateFrom,dateTo,dateCheck) {

 var d1 = dateFrom.split("/");
 var d2 = dateTo.split("/");
 var c = dateCheck.split("/");

 var from = new Date(d1[2], parseInt(d1[1])-1, d1[0]);  // -1 because months are from 0 to 11
 var to   = new Date(d2[2], parseInt(d2[1])-1, d2[0]);
 var check = new Date(c[2], parseInt(c[1])-1, c[0]);

    if(check > from && check < to) {
        return true;
    }
    return false;
}
 
 
Calling method

var availability = dateCheck(startTheoryDate,endTheoryDate,currentDate);
 
And finally it returns boolean value weather it is true or false.