JavaScript determines whether it’s morning or afternoon or evening

let self=this;
let date=new Date();

  if(date.getHours()>=0&&date.getHours()<12){

    self.hoursTip="Good morning"

  }else if(date.getHours()>=12&&date.getHours()<18){

    self.hoursTip="Good afternoon"

  }else{

    self.hoursTip="Good night"

  }
}

Read More: