عَنْ أَبِي هُرَيْرَةَ رَضِيَ اللَّهُ عَنْهُ قَالَ: كَانَ رَسُولُ اللَّهِ صَلَّى اللَّهُ عَلَيْهِ وَآلِهِ وَسَلَّمَ يَعْتَكِفُ الْعَشْرَ الْأَوَاخِرَ مِنْ رَمَضَانَ وَالْعَشْرَ الْأَوْسَطَ، فَمَاتَ حِينَ مَاتَ يَعْتَكِفُ عِشْرَيْنِ يَوْمًا
It is narrated from Sayyiduna Abu Hurairah (may Allah be pleased with him) that the Messenger of Allah (peace and blessings be upon him) used to observe i'tikaf during the last and middle ten days of Ramadan. When the Messenger of Allah (peace and blessings be upon him) passed away, he was observing i'tikaf for twenty days.