Dividing code into schedule based on two halves of the day?

Hello everyone, up front disclosure that this is my first serious attempt at coding anything. Before this I just made some basic modifications to web pages, color/etc.

I'm trying to create a device which runs one code for 18 hours of the day and another code for 6 hours of the day. I want to maintain the temperature and humidity of a room to one set of conditions for one period, then another set for the next period.

I'm using a NodeMCU so I'll either use a NTP server or Blynk app's RTC (similar idea) to get the time rather than a RTC module.

I had no problem setting up the code to read from the temp/humidity sensor or the code to control the relays, but I've had surprising difficulty dividing that code into two separate chunks of the day. I've found ways to trigger specific events (like turning a pin to HIGH) between a certain period of time or at a specific time, but I only want the time to control which code is run, and then that code to be what controls the devices.

Any help with how I might accomplish that? Even a page to read is helpful, I tried researching and got close but just not quite what I need, or I can't quite wrap my head around how to adapt it.

I only want the time to control which code is run, and then that code to be what controls the devices.

start of loop()
  get hour from somewhere
  if (hour > 6 && hour < 11)  //change the test to suit your requirements
  {
    //code here for period 6 to 10
  }
  else
 {
   //code here for the rest of the day
 }
end of loop()

Had a feeling it was fairly simple and I just wasn’t getting it, thank you!

If you have more than a trivial amount of code to run for each period or maybe some common code to run whatever the hour then it is useful to put it in functions with meaningful names and call those instead of all of the code being in loop()