Skip to main content
Source Link
silvesterprabu
  • 1.5k
  • 10
  • 31
  • 46

how to check time range in javascript

i have start and end time along with date.like this

         stime:1pm , etime:2pm , date:2/6/2013

i want to store this start and end time and date into mongodb. so before saving this details

, i should check within this date, this time range is exist or not

so how to do that in javascript. how to check time range already exist or not?

i have tried like this.but it is not working properly. even i don't know my approach ,whether right or wrong ?

i hope that anyone help me to find solution for this.

   var d0 = new Date("01/01/2001 " + "8:30 AM");
   var d1 = new Date("01/01/2001 " + "9:00 PM");
   var d2 = new Date("01/01/2001 " + "8:30 AM");
  var d3 = new Date("01/01/2001 " + "9:00 PM");
 if(d2<d0&&d3<=d0||d2<d1&&d3<=d3)
 {
      console.log("available");
 }else{
     console.log("not available");
 }