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
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
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 like this
Build a BMI and Daily Calorie Calculator with Metric and Imperial Units in HTML
A prompt that makes an AI build Steady Scale, a single-file BMI and calorie calculator using Mifflin-St Jeor, activity levels, unit switching and plain-language ranges.
Build a Countdown Timer to Any Date With a Confetti Finish in One HTML File
Get a polished single-file countdown page with a custom event title, a large days-hours-minutes-seconds display and a confetti-and-chime celebration at zero.
Build a HIIT and Tabata Interval Workout Timer in a Single HTML File
A self-contained interval timer with adjustable work, rest and rounds, color-coded phases, synthesized countdown beeps and a tap-anywhere pause, all in one HTML file.
Build a Keyboard-Friendly To-Do Checklist with Priorities and Filters in One HTML File
A ready-to-paste prompt that makes an AI build a single-file to-do checklist where you can add, reorder, prioritize, filter and export tasks as plain text, all with keyboard shortcuts.
Build a Live Word and Character Counter with Reading Time in One HTML File
A single-file text counter showing live words, characters, sentences, paragraphs, reading and speaking time, and color-coded progress bars for common post length limits.
Build a Loan and Mortgage Calculator with Amortization Table in One HTML File
Get a polished, offline loan and mortgage calculator that shows monthly payment, total interest, an SVG balance chart, extra-payment savings and a full amortization schedule.