Expiry Date Calculator
Calculate expiration dates and manage product shelf life
Result
What is Expiry Date Calculator?
Expiry Date Calculator is an online tool that helps you quickly calculate product expiration dates or estimate production dates. Simply enter the production date and shelf life days to get the exact expiration time, or enter the expiry date to reverse-calculate the production date. It shows the expiry date together with the days remaining and a freshness status (fresh / expiring soon / expired), so you can quickly decide what to use first.
This tool runs locally in your browser, no data upload required, protecting your privacy.
For medical, legal, or financial decisions, the result should be treated as guidance and checked against official rules.
How to Use
How to use
- Select calculation mode: Production→Expiry or Expiry→Production
- Enter date and shelf life days
- Click Calculate to see results
Result Checks
- Confirm whether shelf life starts from production date, packaging date, opening date, or receipt date; these rules are not interchangeable.
- For food, medicine, or regulated goods, use the printed label and local rules as the final authority.
Use Cases
Technical Principle
Expiry math is integer date arithmetic anchored to the production date. The forward path computes expiry = production + shelf_life_days by adding whole days (n * 86400000) to Date.UTC(y, m, d), or calendar-exact months/years with last-day clamping (31 Jan + 1 month = 28/29 Feb; 31 Jan + 30 days = 2 Mar 2025 because February has 28 days). The reverse path computes production = expiry - shelf_life_days the same way. To avoid DST drift around midnight local time, the page anchors arithmetic to UTC via Date.UTC(y, m, d) and adds whole milliseconds (n * 86400000), because Date.setDate in local time crosses DST boundaries with a one-hour offset that can flip the visible date on March and November transitions in the US, October in the EU.
Units are added directly on the calendar: months clamp to the last day of the target month and years count as 12 months, matching the calendar-exact rule used by regulators. The Codex Alimentarius General Standard for the Labelling of Prepackaged Foods (CXS 1-1985, revised) and China's GB 7718-2025 specify shelf life from the date of manufacture or packaging; pharmaceutical expiry follows ICH Q1A (R2) stability testing guidelines and rounds the printed expiry to the last day of the month (so a drug manufactured 2024-08-15 with an 18-month shelf life is labelled 2026-02-28, not 2026-02-15). The remaining-days counter is (expiry_utc - now_utc) / 86400000 rounded with Math.floor for already-elapsed days and Math.ceil for time-until-expiry, and the freshness band is a thresholded comparison: expired when remaining < 0, expiring-soon when 0 ≤ remaining ≤ 30, fresh otherwise.
- Date arithmetic: parse to Y-M-D, anchor to Date.UTC(y, m, d) and add whole days (n * 86400000); months/years are added calendar-exactly with last-day clamping. Never use local-time Date.setDate - it crosses DST boundaries and can flip the visible date.
- Unit handling: months are added calendar-exactly with last-day clamping (31 Jan + 1 month = 28/29 Feb), years as 12 months; pharmaceutical labels follow ICH Q1A (R2) and print the last day of the expiry month.
- Remaining days = (expiry_utc - now_utc) / 86400000, Math.ceil for time until expiry / Math.floor for elapsed days; thresholds: remaining < 0 → expired, 0 ≤ remaining ≤ 30 → expiring soon, otherwise fresh.
- Regulatory anchors vary: food shelf life follows Codex CXS 1-1985 / GB 7718-2025 (from production or packaging); cosmetics use PAO (Period After Opening) starting at first use; medicines use ICH Q1A stability dating.
- After-opening shelf life is independent of the printed expiry and is shorter (e.g. opened olive oil ~3 months despite 24-month sealed shelf life); track the open date separately.
- Browser clock skew (a misconfigured system date) shifts the freshness band; the page reads new Date() rather than a remote time source, so it inherits any client-side clock error.
Examples
Production 2026-01-01 + 730 days = 2028-01-01
Mode: Production -> Expiry
Production date: 2026-01-01
Shelf life: 730 days (2 years)
Expiry date: 2028-01-01
Status: still within shelf lifePharmaceutical: 18-month shelf life
Drug batch lot: A26-0215
Production: 2026-02-15
Shelf life: 18 months (approx 546 days)
Expiry: 2027-08-15
Label note - pharma rule of thumb: expire on the last day
of the month, so the printed date may read 2027-08-31Reverse calculation: Expiry -> Production
Mode: Expiry -> Production
Printed expiry on package: 2028-06-30
Shelf life: 36 months
Produced on or before: 2025-06-30
Use this to verify a supplier's claimed production date
against the batch label.Food storage check
Item: Olive oil 500ml
Production: 2025-12-01
Shelf life: 24 months
Expiry: 2027-12-01
Check: within shelf life; rotate stock by FIFO and plan a discount ~30 days before expiryFAQ
How is the expiry date calculated?
Production date + duration = expiry date. Duration accepts days, months, or years. Months are added by clamping to the last day of the target month (so 31 Jan + 1 month = 28/29 Feb), matching how most regulators interpret 'X months from manufacture'.
Are days remaining counted from today?
Yes. The page shows remaining days from today's date in your local time zone. Negative numbers indicate the product is past its expiry. The status label (fresh / nearing expiry / expired) helps with quick triage.
What's the difference between best-before and use-by?
Best-before is a quality date - food is still safe after, just may have lost peak flavor or texture. Use-by is a safety date - foods may pose health risks past it. Cosmetics and medicines often have a 'PAO' (period after opening) symbol that overrides the printed expiry once opened.
Does the result account for storage conditions?
No. Printed expiry dates assume the manufacturer's recommended storage (cool, dry, sealed, refrigerated, frozen). Heat, humidity, and light shorten real-world shelf life and the page can't model that. Treat the calculated date as an upper bound.
How should I handle 'expired' food or medicine?
For unopened canned goods and dry staples, slightly past best-before is usually fine - check appearance and smell. Dairy, meat, and fish past use-by should be discarded. Medicines past expiry can lose potency and a few are unsafe; do not rely on them for serious treatment.
Can I track multiple products?
This calculator works on one product at a time. For a running inventory, use a dedicated inventory app or a simple spreadsheet.
Is my data uploaded?
No. The calculation runs entirely in your browser. Nothing is uploaded or saved between sessions.
Related Tools
Multi Timer
Free online multi timer to run several countdown timers at once. Start, pause, and reset each timer independently - perfect for cooking multiple dishes, HIIT intervals, and exam invigilation.
Date Difference Calculator
Free online date difference calculator. Calculate days, weeks, months, years between two dates. Precise calculations with hours, minutes, seconds display.
Lunar Calendar Conversion Tool
Free online Gregorian to Lunar calendar converter. Query zodiac, solar terms, traditional festivals. Supports 1900-2100 range, learn lunar calendar info.
Chinese Dynasty Table
Complete chronological table of Chinese dynasties from Xia to Qing dynasty, with dates, founding emperors, and capital cities.
Gaokao Countdown Tool
Gaokao countdown timer showing days, hours, minutes, and seconds until China's National College Entrance Examination, with automatic exam-year detection.
Flip Clock
Free online flip clock with live time, 12/24-hour mode, optional seconds, and fullscreen display for desks, presentations, and focus sessions.
