Normal credit history is 3 years. Eviction for non-payment of rent can stay remain for up to seven years. You can post your version into your credit history.
A civil action like an eviction can remain on a credit report for up to ten years, depending on the law in the state where the eviction was filed. The credit bureaus pick up the information from court records. Even if the matters surrounding the eviction are resolved in time, the civil action will remain on the credit.
Most evictions will remain on a credit report for seven years from the date that they occurred. It is almost always better to avoid being evicted, if you can, by negotiating some other option with the landlord, such as leaving voluntarily.