It was narrated from ‘Umar that he had vowed during the days of Ignorance to spend one night in I’tikaf. He asked the Prophet ﷺ about it, so he commanded him to spend it in I’tikaf. (Using translation from Ibn Mājah 1772)
أَنَّهُ كَانَ عَلَيْهِ لَيْلَةٌ نَذْرٌ فِي الْجَاهِلِيَّةِ يَعْتَكِفُهَا فَسَأَلَ رَسُولَ اللهِ ﷺ «فَأَمَرَهُ أَنْ يَعْتَكِفَ»