Caution: Translations of Quran and Ḥadīth may lead to possible misapplications and misinterpretations. This site is intended for students of sacred knowledge that are proficient in comprehending classical Arabic and have a strong foundation in Islamic sciences. Also note that religious injunctions rely on several aspects beyond what one may glean through reading individual aḥādīth.
quran:18:11

So We cast ˹a cover of sleep˺ over their ears within the cave for a number of years.  

So We smote their ears, that is, We made them sleep, in the Cave for several years, for a ˹fixed˺ number of years.
القرآن:١٨:١١

فَضَرَبْنَا عَلَىٰ آذَانِهِمْ فِي الْكَهْفِ سِنِينَ عَدَدًا  

{فضربنا على آذانهم} أي أنمناهم {في الكهف سنين عددا} معدودة.