The Prophet ﷺ used to spend the last ten days of Ramadan in I’tikaf. One year he was traveling, so the following year he spent twenty days in I’tikaf.
أَنَّ النَّبِيَّ ﷺ كَانَ يَعْتَكِفُ الْعَشْرَ الأَوَاخِرَ مِنْ رَمَضَانَ فَسَافَرَ عَامًا فَلَمَّا كَانَ مِنَ الْعَامِ الْمُقْبِلِ اعْتَكَفَ عِشْرِينَ يَوْمًا