Your pre-departure testing window may vary depending on the country you're travelling to and your vaccination status. You'll need to check the government requirements, and comply with the most stringent requirement that applies to your trip.
If based on hours you need to count back from the scheduled departure time of your first international flight. If the time frame is based on calendar days your day of departure counts as day 0. For example if you are flying on a Friday and your destination requires you to take a test 3 days prior to travel - you can take the test anytime on the Tuesday, Wednesday, Thursday or Friday.
You may consider getting your test as close as possible to departure to allow for any potential flight delays, as long as you can ensure your testing provider can deliver the results in time.