D-Day 倒计时计算器

计算截止日期、考试、旅行、生日或活动的剩余天数。

// about

工具介绍

D-Day 倒计时会将今天与目标日期比较,告诉你还剩多少个日历日,或已经过去多少天。

如何使用

  1. 选择目标日期。
  2. 点击“计算倒计时”。
  3. 查看剩余或已过去的天数。

人们为何使用此工具

  • 适用于截止日期、考试、旅行、生日、发布和预约。
  • 清楚区分未来日期和已过去的日期。
  • 按日历日期计算,不会被小时和分钟干扰。
指南 · 日期与时间 · 约 3 分钟

不差一天的日期计算:倒计时、纪念日、周岁与月龄

离考试还有几天?第 100 天是哪天?宝宝几个月大了?日期计算处处都可能差一天,所以要弄清楚用的是哪条规则。

D-day 计数法把目标日期记为 D,前一天记为 D-1,后一天记为 D+1。剩余天数就是目标日期减去今天。以 2026 年 10 月 28 日为准,12 月 25 日是 D-58。

开始:2026-03-01
经过天数:2026-06-08 是开始后的第 99 天
第几天:  2026-06-08 是第 100 天
是否计算首日会如何改变倒计时和纪念日的结果、如何计算周岁年龄,以及按日历月计算的月龄和月末日期如何处理。
阅读指南 →
用 AI 自己做

用 AI 亲手打造这个工具

想要自己的版本?把下面的任务提示词粘贴到 AI 聊天中,或将技能文件保存到 AI 编程助手。其中包含我们开发此工具时整理的功能、边界情况和测试用例。

提示词和技能以英文提供,AI 工具在任何语言环境下都能很好地理解。

AI 任务提示词

直接粘贴到 Claude、ChatGPT、Gemini 等 AI 聊天中即可。

You are an experienced full-stack web developer. Build a web tool called "倒计时计算器" that meets the requirements below.

## Goal

Build a tool that shows the days remaining until, or elapsed since, a target date in D-day format.

## Core features

- Show D-n, D-Day or D+n for a target date
- Change the reference date
- 'Day number' mode that counts the first day
- Generate milestone lists such as day 100 or 1,000
- Copy the result sentence

## Inputs

- Target date
- Reference date (default today) and mode

## Outputs

- D-day label
- Days remaining or elapsed
- Milestone list

## Edge cases and handling rules

- Compare calendar dates only, not times
- Determine 'today' in the user's time zone
- Handle 29 February in leap years
- Show 'D-Day' when the target is today

## Implementation requirements

- Build it as a single page (HTML, CSS, JavaScript) that runs entirely in the browser, and never send the user's input to a server.
- Make the UI responsive and easy to use on mobile; label every input and keep everything keyboard accessible.
- Add a Copy button for results and show clear, friendly error messages for invalid input.
- Keep the core logic in functions separate from the UI so it can be unit-tested.

## Definition of done (test cases)

- From 2026-10-28, 2026-12-25 is D-58
- Day 100 from 2026-03-01 is 2026-06-08
- Same date shows D-Day

First outline your implementation plan in at most five lines, then write the complete code, and finally explain how to check the test cases above.

技能 (SKILL.md)

在 Claude Code 等 AI 编程助手中保存为 .claude/skills/build-d-day-calculator/SKILL.md,以后开发或修改此工具时可重复使用。

---
name: build-d-day-calculator
description: Use when building or changing a 倒计时计算器 tool. Build a tool that shows the days remaining until, or elapsed since, a target date in D-day format.
---

# Build: 倒计时计算器

## Goal

Build a tool that shows the days remaining until, or elapsed since, a target date in D-day format.

## Workflow

1. Review the required features, inputs and outputs below and ask about anything missing first.
2. Implement the core logic as pure functions separate from the UI.
3. Check the logic against the test cases in the verification list.
4. Build a responsive UI with an input form, a result area and a Copy button.
5. Reproduce each edge case listed under Rules and refine the error messages.

## Core features

- Show D-n, D-Day or D+n for a target date
- Change the reference date
- 'Day number' mode that counts the first day
- Generate milestone lists such as day 100 or 1,000
- Copy the result sentence

## Inputs

- Target date
- Reference date (default today) and mode

## Outputs

- D-day label
- Days remaining or elapsed
- Milestone list

## Rules

- Compare calendar dates only, not times
- Determine 'today' in the user's time zone
- Handle 29 February in leap years
- Show 'D-Day' when the target is today
- Build it as a single page (HTML, CSS, JavaScript) that runs entirely in the browser, and never send the user's input to a server.

## Verification

- [ ] From 2026-10-28, 2026-12-25 is D-58
- [ ] Day 100 from 2026-03-01 is 2026-06-08
- [ ] Same date shows D-Day

交给 AI 时的小技巧

  • 在第一行写明技术栈(如 React、Vue 或纯 HTML),生成的代码会更贴合你的项目。
  • 在接受代码前,请让 AI 运行列出的测试用例并展示结果。
  • 不要把真实密码、客户数据或 API 密钥粘贴到提示词中,请用示例值代替。