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:3:38

At that, Zechariah called upon his Lord, saying, "My Lord, grant me from Yourself a good offspring. Indeed, You are the Hearer of supplication."  

Then, when Zachariah had seen this and realised that the One with power to bring something about in other than its ˹natural˺ time, is able to bring about a child in old age, and with those of his family line all deceased, Zachariah prayed to his Lord, when he entered the sanctuary to pray in the middle of the night, saying, ‘Lord, bestow upon me from You a goodly offspring, a righteous son, verily, You are the Hearer of, ˹You are˺ the One Who answers, supplication’.
القرآن:٣:٣٨

هُنَالِكَ دَعَا زَكَرِيَّا رَبَّهُ ۖ قَالَ رَبِّ هَبْ لِي مِنْ لَدُنْكَ ذُرِّيَّةً طَيِّبَةً ۖ إِنَّكَ سَمِيعُ الدُّعَاءِ  

{هنالك} أي لما رأى زكريَّا ذلك وعلم أن القادر على الإتيان بالشيء في غير حينه قادر على الإتيان بالولد على الكبر وكان أهل بيته انقرضوا {دعا زَكَريَّاُ ربَّه} لما دخل المحراب للصلاة جوف الليل {قال ربِّ هب لي من لدنك} من عندك {ذرية طيبة} ولدا صالحا {إنك سميع} مجيب {الدعاء}.