function calculateFast() {
var startDateVal = document.getElementById('fastStartDate').value;
var startTimeVal = document.getElementById('fastStartTime').value;
var duration = parseInt(document.getElementById('fastDuration').value);
if (!startDateVal || !startTimeVal) {
alert('Please select both a start date and time.');
return;
}
var startDateTime = new Date(startDateVal + 'T' + startTimeVal);
var endDateTime = new Date(startDateTime.getTime() + (duration * 60 * 60 * 1000));
var options = { weekday: 'long', month: 'long', day: 'numeric', hour: '2-digit', minute: '2-digit' };
var endString = endDateTime.toLocaleDateString('en-US', options);
document.getElementById('endTimeDisplay').innerText = endString;
var eatWindowEnd = new Date(endDateTime.getTime() + ((24 – duration) * 60 * 60 * 1000));
var eatOptions = { hour: '2-digit', minute: '2-digit' };
document.getElementById('eatingWindowDisplay').innerText = endDateTime.toLocaleTimeString([], eatOptions) + " to " + eatWindowEnd.toLocaleTimeString([], eatOptions);
var milestones = document.getElementById('milestones');
milestones.innerHTML = ";
var stages = [
{ h: 12, desc: "Blood sugar levels drop and insulin decreases." },
{ h: 14, desc: "Body begins utilizing stored fat for energy." },
{ h: 16, desc: "Growth hormone increases significantly (Fat burning zone)." },
{ h: 18, desc: "Ketogenesis begins as glycogen stores deplete." },
{ h: 24, desc: "Autophagy (cellular repair) likely initiated." }
];
for (var i = 0; i = stages[i].h) {
var li = document.createElement('li');
li.innerHTML = "" + stages[i].h + " Hours: " + stages[i].desc;
milestones.appendChild(li);
}
}
document.getElementById('fastingResult').style.display = 'block';
}
// Set default date to today
window.onload = function() {
var today = new Date().toISOString().split('T')[0];
document.getElementById('fastStartDate').value = today;
var now = new Date();
var hours = String(now.getHours()).padStart(2, '0');
var minutes = String(now.getMinutes()).padStart(2, '0');
document.getElementById('fastStartTime').value = hours + ':' + minutes;
};
How to Use the Fasting Calculator
Intermittent fasting (IF) is an eating pattern that cycles between periods of fasting and eating. It doesn't specify which foods you should eat but rather when you should eat them. Our calculator helps you map out your specific fasting window so you can stay consistent with your health goals.
Common Fasting Protocols
16:8 (The Leangains Method): This involves skipping breakfast and restricting your daily eating period to 8 hours, such as 1 PM to 9 PM. Then you fast for 16 hours in between.
18:6 (Warrior Lite): A slightly more aggressive protocol that provides an 18-hour fasting window, often associated with higher levels of fat oxidation.
20:4 (The Warrior Diet): This involves eating small amounts of raw fruits and vegetables during the day and eating one huge meal at night within a 4-hour window.
OMAD (One Meal a Day): A 23:1 or 24-hour fast where you consume all your daily calories in a single sitting.
What Happens During Your Fast?
When you use the calculator, we display "Metabolic Milestones." These are general scientific approximations of what occurs in the human body during caloric deprivation:
Hours Fasted
Metabolic State
4-8 Hours
Blood sugar falls; insulin production stops.
12 Hours
The "Burning Zone" – Digestive system rests.
14-16 Hours
Increased lipolysis (fat breakdown).
24+ Hours
Autophagy – the body begins recycling damaged cells.
A Practical Example
If you finish your last meal on Monday at 8:00 PM and choose a 16-hour fast, the calculator will show that your fast ends on Tuesday at 12:00 PM. Your eating window will then be open for 8 hours, allowing you to consume your meals between 12:00 PM and 8:00 PM, at which point the cycle repeats.
Disclaimer: Always consult with a healthcare professional before starting a new fasting regimen, especially if you have underlying health conditions, are pregnant, or have a history of disordered eating.