Comet Siding Spring (C/2013 A1) had a close encounter with Mars on October 19, 2014. On that date the comet passed within approximately 87,000 miles of Mars (or about one-third the distance between Earth and the Moon).
Some Hubble images use data acquired over several days of observations.