Need to find all the hours between a person wake up time and sleep time in jquery -


i have wakeup_time , sleep_time

eg: wakeup_time=09:00 pm , sleep_time= 11:00 am

i need find hours(12 h format) between 2 time.

the wakeup , sleep time varry.

expected result : 9 pm, 10pm, 12pm, 1 am, ......,10 , 11

another 1 . try this.

var id=0;         var unit=wakeup_unit;         var time;         for(var i=0;i<=totalhours;i++){         id=wakeup_time+i;          if(id>=12){             if(id==12){                     time=id;                     if(wakeup_time==12){                      }else{                         if(unit=="am"){                             unit="pm";                         }else if(unit=="pm"){                             unit="am";                         }else{                             unit=unit;                         }                     }                  }else{                     time=id-12;                     if(time>=12){                         if(time==12){                             if(wakeup_time==12){                      }else{                         if(unit=="am"){                         unit="pm";                     }else if(unit=="pm"){                         unit="am";                     }else{                         unit=unit;                     }                     }                         }else{                             time=time-12;                         }                     }              }          }else{             time=id;         }         console.log(time +" "+ unit);         if ((wakeup_unit == "am") && (sleep_unit == "pm")) {                         if (wakeup_time == 12 && sleep_time != 12) {                             var totalhours = (sleep_time + 12);                         } else if(wakeup_time != 12 && sleep_time == 12){                         var totalhours = (sleep_time -wakeup_time);                         }else if (wakeup_time == 12 && sleep_time == 12) {                             var totalhours = 12;                         } else {                             var totalhours = (sleep_time > wakeup_time) ? ((sleep_time + 12) - wakeup_time) : ((sleep_time + 12) - wakeup_time);                         }                     } else if ((wakeup_unit == "pm") && (sleep_unit == "am")) {                         if (wakeup_time == 12 && sleep_time != 12) {                             var totalhours = sleep_time + 12;                         } else if (wakeup_time != 12 && sleep_time == 12) {                             var totalhours = sleep_time - wakeup_time;                         } else if (wakeup_time == 12 && sleep_time == 12) {                             var totalhours = 12;                         } else {                             var totalhours = (sleep_time > wakeup_time) ? 24 - ((wakeup_time + 12) - sleep_time) : 24 - ((wakeup_time + 12) - sleep_time);                         }                     } else if ((wakeup_unit == "am") && (sleep_unit == "am")) {                         if (wakeup_time == 12 && sleep_time == 12) {                             var totalhours = 0;                         }else if (wakeup_time == 12 && sleep_time != 12) {                             var totalhours = sleep_time;                         }else if (wakeup_time != 12 && sleep_time == 12) {                             var totalhours = sleep_time+wakeup_time;                         }else {                             var totalhours = (sleep_time > wakeup_time) ? (sleep_time - wakeup_time) : 24 - (wakeup_time - sleep_time);                         }                      } else if ((wakeup_unit == "pm") && (sleep_unit == "pm")) {                         if (wakeup_time == 12 && sleep_time == 12) {                             var totalhours = 0;                         }else if (wakeup_time == 12 && sleep_time != 12) {                             var totalhours = sleep_time;                         }else if (wakeup_time != 12 && sleep_time == 12) {                             var totalhours = sleep_time+wakeup_time;                         } else {                             var totalhours = (sleep_time > wakeup_time) ? (sleep_time - wakeup_time) : 24 - (wakeup_time - sleep_time);                         }                      } else {                         console.log("this should not come @ all");                     } 

Comments

Popular posts from this blog

aws api gateway - SerializationException in posting new Records via Dynamodb Proxy Service in API -

asp.net - Problems sending emails from forum -