'How to get "Hour" of the day in Google Apps script

I am writing a Script, which I want to NOT run during an interval of the day (since I have other scripts operating on the sheet during that time frame). I want to insert one line of code at the beginning of my function which will just perform a quick check whether the current time of the day is in that time interval or not, but I am unable to do so. Here is the code: //This the code block which will prevent night time running

var d = new Date();
var hours = d.getHours(); if(hours.toString().length==1){var hours = '0'+hours;}

Logger.log(hours);
  if ((hours >= 1) || (hours <= 6))
    return;

// Basically making the code not run at night time

But this is giving errors. The time is coming in UTC even when explicitly time zone is mentioned. Can someone please help?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source