Thanks all you to help.
Where exactly are you setting it? What specific smartapp or routine?
SmartThings normally does this transition very well, it’s one of their advantages over some of the competition. You should be able to set a restriction on smartlighting or a routine that goes from sunset to sunrise, for example, or from 10 PM to 7 AM.
Can you show us a screenshot of where you set up the times?
edited to add I see this is a follow-up question to a coding problem you were having earlier. Some of the coders will have to help you with that, I can’t read code since I rely on text to speech.