When citing the impact factor of a journal in which your paper was published, you should use the impact factor for the year in which your paper was published. This is because the impact factor is calculated based on the number of citations received by articles published in a particular journal in a specific year.
For example, if your paper was published in 2022, you should use the impact factor for the year 2022 when citing the impact factor of the journal. The impact factor for the current year may not accurately reflect the impact of the journal at the time your paper was published.
I agree with the comment that it is the year that you published... most of the journals I have published in got a higher IF in future years... that is both frustrating and funny.