As far as I know, ChatGPT has knowledge up until 2021, but they are working on it to keep it updated.
As far the code you posted seems good. You have to try it out though, to see for yourself.
Thanks, will do. ChatGPT has knowledge up to September 2021.