How this is worked out, and its limits
CDC: adults 18 to 60 need 7 or more hours; 61 to 64 need 7 to 9. Bedtime = wake time − sleep − time to fall asleep. Caffeine has a half-life of about 5 hours, so the last cup goes 8 hours before bed; screens an hour before; a heavy meal 2 to 3 hours before (standard AASM advice).
References: CDC, how much sleep do I need
General information for adults, not a diagnosis or a personal prescription. It comes from sources published on the internet and can contain mistakes, so please check with your doctor. Nothing you enter is stored. Full disclaimer