I bought my iPhone 5S used in December 2013, and sold it in mid-2017, in part because I expected that iOS 11 that year would drop support. Nope; both it and iOS 12 supported the 5S, meaning that it could run the newest iOS until September 2019. As mentioned elsewhere, iOS 12 still gets security updates today.
(Based on the difference between the purchase and sale prices I ended up paying about $10 a month to use the 5S for 3.5 years. I sold it after replacing it with an SE that I made money on at purchase because of an insane promotion at Best Buy.)
It was released September 2013 (6.5yr), discontinued September 2014 for the 64GB version (5.5yr), March 2016 for the 16, 32GB versions (4yr).