[removed] IF time >= 9:30 then

前端 未结 8 2048
一整个雨季
一整个雨季 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");
    }
    
    0 讨论(0)
  • 2020-12-30 11:58

    Try this:

    var now = new Date(); 
    var hour = now.getHours(); 
    var mintues = now.getMinutes();
    
    if(
            (hour*60 + mintues) > 570 && 
            hour <= 11
        )
    {
        document.write(now); 
    }
    
    0 讨论(0)
提交回复
热议问题