Occasionally, Dungeons & Dragons encounters benefit from using real-world time as an enemy or complicating factor. One of the major jobs of a D&D Dungeon Master is to plan engaging and exciting encounters for their players. The last thing that a DM wants to do is put a tedious or boring encounter on the table, which is why DMs use various complicating factors to prevent every encounter from feeling like a straight-forward combat. From the use of difficult terrain or environmental factors to providing mid-round complications, there are lots of ways to spice up a combat encounter and turn it into a memorable experience.
One tool that can be very effective in the right situations is the use of a real-world timer or a countdown factor, both in and out of combat. The timer is most effective as a stand-in for some cataclysmic danger - perhaps the players have 2 hours of real world time before a volcano is due to erupt or a catastrophic magical phenomenon is set to occur. Meanwhile, countdowns are more useful in combat - with players having a set number of rounds to accomplish some sort of goal before a villain succeeds at summoning a monster or completes some other fiendish ritual.
Timers have a controversial history in Dungeons & Dragons, in part because they feel like a very immersion-ruining component to a game that's about narrative storytelling. Some DMs enforce arbitrary time limits on player decision making, which can limit creativity and turn combat into a stressful situation. I don't recommend ever trying to time a player's turn - instead, give the group a time limit and let the players dictate the speed and urgency of the encounter. Providing the group with a time limit will usually lead to the players to efficiently carry out plans on their own and will work together to keep an encounter moving.
One key to timed encounters or sessions is to clearly lay out the parameters in advance so that players don't feel blindsided by the extra rules, and to present an extra incentive for the players to help offset the extra rules. For instance, when running a timed session, you may want to provide players with a "free" short rest outside of combat with no narrative penalty, which can help players from being too conservative with their decisions. You may also want to provide players with some shiny distractions to complicate a session further. Giving players optional side objectives to complete for additional rewards or adding a treasure room to a dungeon may incentivize players to push their characters to the limit as they try to clear their main goal under the time limit.
The use of a timer can provide some extra-memorable moments in Dungeons & Dragons as it can add to the feeling of danger and accomplishment in missions. During one recent session, I gave my players a two-hour time limit to successfully board a clockwork nautilus to complete a specific set of missions. As the clock ticked down into the final minutes, it seemed more and more likely that the players would end up failing when the time limit expired. It made their final choices that much more weighty and provided an extra level of accomplishment when they completed their task just as the timer expired.
Like any optional rule in Dungeons & Dragons, the key to timers and countdowns is to use them wisely. Using timers to add an extra level of tension is great for special occasions or boss fights, but they don't need to be added into every single encounter. When used correctly, timers bring an extra level of excitement to Dungeons & Dragons and they can be a great way to spur your players to even greater heights.