If you take the boot light out, there's a little diode that's pushed into a crimp terminal. Sometimes they come loose and the connection is then inconsistent.
Can't think of any reason why the time of day would affect it! Unless it's tied into the rain/light sensor for the headlights? But I doubt it! Or maybe the boot latch switch is faulty and it's turning itself off after a period of being left on......making you think it's not working when you open the boot?
My boot light wasn't working at all when I got the car. Replaced the latch mechanism (the switch is an integral part of it) and it's been golden ever since. You could bridge the connections for the bulb in the latch harness, day and night, to verify the wiring to the bulb is at least solid? If that's all good, I reckon the latch is duff.