Grabbing a cup of joe shortly after waking up might seem like the best way to beat the morning grogginess and prep for the day ahead. But drinking coffee first thing in the morning isn't doing you any favors, according to science.

That’s largely because of how similar caffeine is to cortisol, a hormone that naturally occurs in your body and makes you feel alert. If you drink your coffee when your body is already at peak cortisol levels you’re not going to get the same energy boost as you would when your cortisol level is low.

Your body begins generating cortisol pretty much as soon as you get up, and levels hit their peak around two hours after you wake. That means if you wake at 6:30, cortisol levels will peak between 8 and 9 am. Your cortisol levels will peak again around noon and again in the early evening, somewhere between 5:30 and 6:30 pm.

So, if you’re looking for peak coffee effectiveness, you’re actually better off having your first cup of coffee somewhere between 9:30 and 11:30 am.

Of course, the exact time will change based on what your typical sleep patterns are. Later risers will have to push those numbers ahead a bit and earlier risers should pull them back.

Now, you might think that putting off your first coffee can’t possibly be worth it, but there are other benefits to getting that caffeine fix later on.

That’s because having caffeine when cortisol levels are high can actually make you feel stressed out. That’s right, higher levels of cortisol mean higher levels of stress, and since your body sees caffeine as pretty darn close to cortisol, drinking coffee during peak cortisol times can inadvertently stress you out.

In fact, drinking coffee too late in the day can make you stressed even when your cortisol levels are low. Having caffeine latter in the day can contribute to insomnia which, you guessed it, is probably going to make you feel even more stressed the next day.

When you put this all together, it means that you have an approximately two-hour window somewhere between three and five hours after you get up, where you can get the get the absolute most out of your coffee habit.