“Heute Nacht” in German can mean “last night” and “tonight”.
You have to rely on context and grammar.
“Heute Nacht hatte ich einen Albtraum” = “Last night I had a nightmare”
You are more likely to say that in the morning.
“Heute Nacht ist Vollmond” = “Tonight is/will be a full moon”
You are more likely to say that in the afternoon or evening.
There are variants:
“Letzte Nacht hatte ich einen Albtraum” = Last night … (that’s unequivocally)
“Diese Nacht hatte ich einen Albtraum”
“Diese Nacht ist Vollmond”