Cayenne MQTT scheduling

Hi

I am busy with a project to automate lights to come on at certain times of the day. How would I be able to add to the if statement that if current time is greater than 18:00 and less than 06:00 then the light must turn on but also work with the input from the cayenne app. I am using python script as follows:

#!/usr/bin/env python
import os
import glob
import cayenne.client
import time
import RPi.GPIO as GPIO

GPIO.setmode(GPIO.BCM)
GPIO.setup(21, GPIO.OUT)
GPIO.setwarnings(False)


# Cayenne authentication info. This should be obtained from the Cayenne Dashboard.
MQTT_USERNAME  = "my username"
MQTT_PASSWORD  = "my password"
MQTT_CLIENT_ID = "my client ID"


# The callback for when a message is received from Cayenne.
def on_message(message):
    print("message received: " + str(message))
    if (message.channel == 1) and (message.value == "1"):
        GPIO.output(21, 0)
    if (message.channel == 1) and (message.value == "0"):
        GPIO.output(21, 1)
        
client = cayenne.client.CayenneMQTTClient()
client.on_message = on_message
client.begin(MQTT_USERNAME, MQTT_PASSWORD, MQTT_CLIENT_ID)

i=0
timestamp = 0

while True:
    client.loop()

how are you planning to get the time in your code?