PERF: Improve performance in to_csv with date format for index
- [x] closes #39413
- [x] Ensure all linting tests pass, see [here](https://pandas.pydata.org/pandas-docs/dev/development/contributing_codebase.html#pre-commit) for how to run them
- [x] whatsnew entry

Before:
```
%timeit df.to_csv(date_format='%Y-%m-%d %H:%M:%S')
1.05 s ± 11.5 ms per loop (mean ± std. dev. of 7 runs, 1 loop each)
```
afterwards:
```
%timeit df.to_csv(date_format='%Y-%m-%d %H:%M:%S')
392 ms ± 4.31 ms per loop (mean ± std. dev. of 7 runs, 1 loop each)
```
thanks @phofl wouldn't object to addtitional benchmarks as specified in the OP We have some of them already, will check and add as necessary