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:25

And they remained in their cave for three hundred years and exceeded by nine.  

And they tarried in the Cave three hundred (read ˹with tanwīn˺ thalāthami’atin) years (sinīn is an explicative supplement to thalāthami’atin, ‘three hundred’): these three hundred years in the case of the People of the Cave were solar years; but for ˹the number of˺ lunar ones, the Arabs add nine years thereto, and this is mentioned in His saying: and add nine, that is, nine years; in other words three hundred solar years, while three hundred and nine lunar ones.
القرآن:١٨:٢٥

وَلَبِثُوا فِي كَهْفِهِمْ ثَلَاثَ مِائَةٍ سِنِينَ وَازْدَادُوا تِسْعًا  

{ولبثوا في كهفهم ثلاث مائة} بالتنوين {سنين} عطف بيان لثلاثمائة وهذه السنون الثلاثمائة عند أهل الكهف شمسية وتزيد القمرية عليها عند العرب تسع سنين وقد ذكرت في قوله {وازدادوا تسعا} أي تسع سنين فالثلاثمائة الشمسية: ثلاثمائة وتسع قمرية.