We do not know exactly when Kapila lived, but he was presumably alive in the Vedic era (5th-10th centuries BCE). However, the oldest Sāṅkhya writing dates from the 5th century CE.
Kapila’s students supposedly built the city of Kapilavastu, where the Buddha lived until he left to become an ascetic at age 29.
Patañjali is thought to have lived around 400 CE.