The Prophet ﷺ said, "Instruct a child to pray when he reaches seven years of age, and when he reaches ten, discipline him for neglecting it."
حدثنا محمد بن عيسى يعني ابن الطباع حدثنا إبراهيم بن سعد
قال النبي ﷺ مروا الصبي بالصلاة إذا بلغ سبع سنين وإذا بلغ عشر سنين فاضربوه عليها
Its isnad is hasan. Tirmidhi transmitted it in "Prayer," in the chapter on when a child is to be commanded to pray, and Ibn Khuzayma graded it sahih, hadith 407, from the hadith of Abdul-Malik bin Rabi, and he said, hasan sahih, hadith 1002, and Hakim graded it on the standard of Muslim, 1/201, and Dhahabi agreed with him.