Caffeine has nothing to do with when you can drink it.
I mean, that's just not true.
There have been numerous studies that had conclusively proven caffeine, when taken close to bed, measurably worsens sleep quality. Yes, even when the participants claimed they had no trouble getting asleep.