Period Calculator

Period Calculator

Use this calculator to estimate the future period days or the most probable ovulation days. Tracking your menstrual cycle can help with family planning and understanding your body's patterns.

i
Modify the values and click the Calculate button to use
Result
Period Days
Ovulation Day
Fertile Window
# Period Start Period End Approx. Ovulation Fertile Window

Next Fertile Window: ' + formatShortDate(first.fertileStart) + ' – ' + formatShortDate(first.fertileEnd) + '

'; document.getElementById('result-section').classList.add('visible'); } function clearForm() { document.getElementById('result-section').classList.remove('visible'); document.getElementById('result-body').innerHTML = ''; calculatedResults = []; } function exportToPDF() { if (calculatedResults.length === 0) { alert('Please calculate your period dates first.'); return; } if (typeof window.jspdf === 'undefined') { alert('PDF library is loading. Please try again in a moment.'); return; } try { var jsPDF = window.jspdf.jsPDF; var doc = new jsPDF(); var pageW = 210, marginL = 14, tableW = pageW - 2 * marginL; // Header doc.setFillColor(90, 154, 58); doc.rect(0, 0, pageW, 28, 'F'); doc.setTextColor(255, 255, 255); doc.setFontSize(22); doc.setFont(undefined, 'bold'); doc.text('Period Calculator Results', pageW / 2, 17, { align: 'center' }); // Input Summary var y = 36; doc.setDrawColor(90, 154, 58); doc.setLineWidth(0.5); doc.roundedRect(marginL, y - 4, tableW, 38, 3, 3, 'S'); doc.setFillColor(90, 154, 58); doc.roundedRect(marginL, y - 4, tableW, 10, 3, 3, 'F'); doc.rect(marginL, y + 2, tableW, 4, 'F'); doc.setTextColor(255, 255, 255); doc.setFontSize(12); doc.setFont(undefined, 'bold'); doc.text('Input Summary', marginL + 5, y + 3); y += 14; doc.setTextColor(60, 60, 60); doc.setFontSize(10); var month = parseInt(document.getElementById('period-month').value); var day = parseInt(document.getElementById('period-day').value); var year = parseInt(document.getElementById('period-year').value); var duration = document.getElementById('period-duration').value; var cycleLen = document.getElementById('cycle-length').value; var inputs = [ ['First Day of Last Period', fullMonths[month] + ' ' + day + ', ' + year], ['Period Duration', duration + ' days'], ['Average Cycle Length', cycleLen + ' days'] ]; inputs.forEach(function(row) { doc.setFont(undefined, 'bold'); doc.text(row[0] + ':', marginL + 5, y); doc.setFont(undefined, 'normal'); doc.text(row[1], marginL + 75, y); y += 7; }); // Legend y += 10; doc.setFontSize(8); doc.setFont(undefined, 'bold'); doc.setTextColor(60, 60, 60); doc.text('Legend:', marginL, y); doc.setFillColor(220, 53, 69); doc.circle(marginL + 22, y - 1.2, 2, 'F'); doc.setFont(undefined, 'normal'); doc.setTextColor(80, 80, 80); doc.text('Period Days', marginL + 26, y); doc.setFillColor(90, 154, 58); doc.circle(marginL + 55, y - 1.2, 2, 'F'); doc.text('Ovulation Day', marginL + 59, y); doc.setFillColor(0, 123, 255); doc.circle(marginL + 95, y - 1.2, 2, 'F'); doc.text('Fertile Window', marginL + 99, y); // Table y += 10; doc.setFontSize(13); doc.setFont(undefined, 'bold'); doc.setTextColor(45, 90, 30); doc.text('Predicted Period & Ovulation Dates', marginL, y); y += 8; var colWidths = [12, 40, 40, 40, 50]; var headers = ['#', 'Period Start', 'Period End', 'Ovulation', 'Fertile Window']; doc.setFillColor(90, 154, 58); doc.rect(marginL, y - 5, tableW, 10, 'F'); doc.setTextColor(255, 255, 255); doc.setFontSize(9); doc.setFont(undefined, 'bold'); var xOff = marginL + 2; headers.forEach(function(h, i) { doc.text(h, xOff + 2, y + 1); xOff += colWidths[i]; }); y += 10; doc.setFontSize(9); calculatedResults.forEach(function(r, index) { if (y > 265) { doc.addPage(); y = 20; doc.setFillColor(90, 154, 58); doc.rect(marginL, y - 5, tableW, 10, 'F'); doc.setTextColor(255, 255, 255); doc.setFont(undefined, 'bold'); var x2 = marginL + 2; headers.forEach(function(h, i) { doc.text(h, x2 + 2, y + 1); x2 += colWidths[i]; }); y += 10; } var rowH = 9; if (index % 2 === 0) { doc.setFillColor(245, 245, 245); doc.rect(marginL, y - 5, tableW, rowH, 'F'); } doc.setDrawColor(220, 220, 220); doc.setLineWidth(0.2); doc.line(marginL, y + rowH - 5, marginL + tableW, y + rowH - 5); xOff = marginL + 2; doc.setFont(undefined, 'bold'); doc.setTextColor(80, 80, 80); doc.text('' + (index + 1), xOff + 3, y + 1); xOff += colWidths[0]; doc.setTextColor(220, 53, 69); doc.setFont(undefined, 'bold'); doc.text(formatDate(r.periodStart), xOff + 2, y + 1); xOff += colWidths[1]; doc.text(formatDate(r.periodEnd), xOff + 2, y + 1); xOff += colWidths[2]; doc.setTextColor(90, 154, 58); doc.text(formatDate(r.ovulationDate), xOff + 2, y + 1); xOff += colWidths[3]; doc.setTextColor(0, 123, 255); doc.setFont(undefined, 'normal'); doc.setFontSize(8); doc.text(formatShortDate(r.fertileStart) + ' - ' + formatShortDate(r.fertileEnd), xOff + 2, y + 1); doc.setFontSize(9); y += rowH; }); // Notes y += 12; doc.setFillColor(250, 250, 250); doc.roundedRect(marginL, y - 4, tableW, 28, 2, 2, 'F'); doc.setDrawColor(200, 200, 200); doc.setLineWidth(0.3); doc.roundedRect(marginL, y - 4, tableW, 28, 2, 2, 'S'); doc.setFontSize(9); doc.setFont(undefined, 'bold'); doc.setTextColor(80, 80, 80); doc.text('Important Notes:', marginL + 4, y + 2); doc.setFont(undefined, 'normal'); doc.setTextColor(100, 100, 100); doc.setFontSize(8); y += 8; doc.text('• Ovulation is estimated at 14 days before the next period start.', marginL + 4, y); y += 5; doc.text('• Fertile window spans 5 days before ovulation through 1 day after.', marginL + 4, y); y += 5; doc.text('• These are estimates only. Consult a healthcare provider for medical advice.', marginL + 4, y); // Footer doc.setFontSize(8); doc.setTextColor(180, 180, 180); doc.text('Generated on ' + new Date().toLocaleString(), pageW / 2, 285, { align: 'center' }); doc.save('period-results-' + new Date().toISOString().split('T')[0] + '.pdf'); } catch (error) { console.error('Error generating PDF:', error); alert('There was an error generating the PDF. Please try again.'); } } window.addEventListener('load', init);