[removed] IF time >= 9:30 then

前端 未结 8 2050
一整个雨季
一整个雨季 2020-12-30 11:25

I\'m trying to write a statement that says \"if time is this and less than that then\". I can use get hours and get min. However, I\'m having problems combining a time suc

8条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-12-30 11:54

    I don't quite fully understand your question but hope this helps.

    c = new Date();
    nhour  = c.getHours();
    nmin   = c.getMinutes();
    
    if(nmin <= 9) {
        nmin = "0" + nmin;
    }
    if(nhour <= 9) {
        nhour = "0" + nhour;
    }
    
    newtime = nhour + "" + nmin;
    
    if(newtime <= 0930){
        alert("It is before 9:30am or earlier");
    }
    

提交回复
热议问题