For Roth IRA - does it matter in which year I earned the money for contribution?

For example, for my 2022 Roth IRA contribution, for the money I am going to contribute, does it matter if I earned the money today (like, Jan 15, 2023) instead of earned it during 2022? Or I can only contribute the money that I earned during 2022 to my 2022's limit? 

 

Thanks!