Build an Age and Date Difference Calculator in a Single HTML File

A ready-to-paste prompt that builds a polished age calculator showing exact years, months and days, total days, birth weekday and next-birthday countdown.

You getone complete HTML file in a single code block, then 3 short ideas to extend it.

The prompt

Prompt
You are a front-end developer who builds polished, dependable utility pages. Build "Datewise", an age and date difference calculator, as one self-contained HTML file. The user picks a start date (usually a birthday) and an end date that defaults to today. Results update instantly whenever either date changes.

Rules:
1. Show the exact difference as years, months and days with calendar-correct month borrowing, so Jan 31 to Mar 1 is 1 month 1 day. Use UTC date math so daylight saving never shifts a day.
2. Below it, show stat cards for:
   - total days, with hours
   - weeks plus leftover days
   - total months
   - the weekday of the start date
   - days until the next birthday, with the age turned and its weekday
   - the next 1,000-day milestone and its date
   Treat Feb 29 birthdays as Feb 28 in common years.
3. If the dates are reversed, compare them in reverse order and show a short note. If a date is empty or invalid, show a friendly message instead of broken numbers.
4. Include "Use today" and "Swap" buttons, labelled native date inputs, visible focus outlines and an aria-live result region.
5. Layout:
   - warm off-white page with white cards
   - one teal accent and one rust accent
   - a clear type scale
   - inputs that stack below 600px
   - fits 360-1280px wide
6. Use no external libraries, fonts, network, storage, forms or alerts. Respect prefers-reduced-motion.

Output format: one complete HTML file in a single code block, then 3 short ideas to extend it.

Example output

One HTML file. Save it and open it in any browser.Open full screen

Example: Datewise, an age and date difference calculator.

Pick a birthday and an end date (today by default) to see the exact gap in years, months and days. Cards below show:

  • total days and hours
  • weeks and months
  • the weekday you were born
  • a countdown to your next birthday
  • your next 1,000-day milestone

Try Swap with reversed dates, or tap Try a leap-day birthday to see how Feb 29 is handled.

Written by AI from this prompt. Your results will vary.

Tips and common edits

Why this works

  • Spelling out month borrowing and UTC math stops the classic off-by-one and negative-day bugs in age calculators.
  • Naming every stat card and edge case (reversed dates, Feb 29, empty input) gets a complete tool on the first answer.
  • Native labelled date inputs give keyboard, touch and screen reader support with no extra code.

Paste the prompt into ChatGPT, Claude or Gemini. Save the returned code as datewise.html and open it in any browser, or view it in the chat's preview or canvas panel.

Common edits

  • Swap the teal and rust accents for your brand colours, or add a dark theme with a prefers-color-scheme block.
  • Add a business-days count that skips weekends, or a list of upcoming round-number milestones like 10,000 days.

Prompt details

By
Prompts-GPT editors
Published

Did this prompt work?

Keep exploring

More in Mini Apps & Tools