You must have been physically present in the UK exactly 5 years before the date the Home Office receives your application (or 3 years if applying based on your marriage to a British Citizen.
For example, if the Home Office receives your application on 20 June 2022 but you left the UK on 10 June 2017 and returned to the UK on 25 June 2017 you will not qualify. You would need to wait until 24 June 2022 to apply.
Unlike with ILR applications, you cannot apply for citizenship 28 days before you reach the qualifying period. Instead you must wait until you have held ILR for a full 12 months before you apply.