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:12:22

And when Joseph reached maturity, We gave him judgment and knowledge. And thus We reward the doers of good.  

And when he reached his prime — which was at 30 or 33 years of age — We gave him ˹power of˺ judgement, wisdom, and knowledge, understanding in ˹matters of˺ religion, before his call to prophethood. Thus, just as We rewarded him, We reward those who are virtuous, to ˹the good˺ of their souls.
القرآن:١٢:٢٢

وَلَمَّا بَلَغَ أَشُدَّهُ آتَيْنَاهُ حُكْمًا وَعِلْمًا ۚ وَكَذَٰلِكَ نَجْزِي الْمُحْسِنِينَ  

{ولما بلغ أشده} وهو ثلاثون سنة أو وثلاث {آتيناه حكما} حكمة {وعلما} فقها في الدين قبل أن يبعث نبيا {وكذلك} كما جزيناه {نجزي المحسنين} لأنفسهم.

See similar narrations below:

Collected by Qurʾān
quran:28:14

And when he attained his full strength and was ˹mentally˺ mature, We bestowed upon him judgement and knowledge. And thus do We reward the doers of good.  

And when he came of age, namely, at 30 or 33, and ˹then˺ was ˹fully˺ mature, that is, when he reached the age of 40, We gave him judgement, wisdom, and knowledge, comprehension of religious matters before he was sent as a prophet. And so, just as We rewarded him, do We reward those are virtuous, to their own souls.
القرآن:٢٨:١٤

وَلَمَّا بَلَغَ أَشُدَّهُ وَاسْتَوَىٰ آتَيْنَاهُ حُكْمًا وَعِلْمًا ۚ وَكَذَٰلِكَ نَجْزِي الْمُحْسِنِينَ  

{ولما بلغ أشده} وهو ثلاثون سنة أو وثلاث {واستوى} أي بلغ أربعين سنة {آتيناه حكماً} حكمة {وعلماً} فقهاً في الدين قبل أن يبعث نبياً {وكذلك} كما جزيناه {نجزي المحسنين} لأنفسهم.