A simple, interactive date calculator that allows you to add or subtract years, months, weeks, days, hours, and minutes from a given date. Results update automatically as you change values.
Download the widget files and host them on your own server:
The ZIP file contains both ESM (ES modules) and UMD (Universal Module Definition) builds.
After downloading, extract the files to your website directory and include ONE of these script tags in your HTML:
<!-- Modern browsers: ESM build --> <script type="module" src="/path/to/gema369-date-calc.es.js"></script> <!-- Legacy fallback: UMD build --> <script src="/path/to/gema369-date-calc.umd.js"></script>
Note: Replace "/path/to/" with the actual path where you uploaded the widget files on your server.
Place this HTML where you want the widget to appear:
<gema369-date-calculator initial-date="2025-05-20"></gema369-date-calculator>
initial-date
(optional)ISO format YYYY-MM-DD. Defaults to today's date if omitted.
Example: 2025-05-20
You can customize the appearance of the widget using CSS. Here's an example:
gema369-date-calculator { /* change font */ font-family: "Roboto", sans-serif; /* change border color */ border: 1px solid #888; border-radius: 0.5rem; padding: 1rem; max-width: 600px; margin: 0 auto; } /* target internal elements */ gema369-date-calculator .results { margin-top: 1.5em; padding-top: 1em; border-top: 1px solid #eee; }
You can interact with the widget programmatically:
// Get a reference to the widget const widget = document.querySelector('gema369-date-calculator'); // Set a new initial date widget.setAttribute('initial-date', '2025-12-31');