In this tutorial, you will learn how to build a sleek, dark-themed web application that takes a user’s date of birth and converts it into a fully spelled-out sentence. By the end, you’ll have a functional tool that transforms a date like 12/25/1990 into “December twenty-fifth, nineteen ninety,” all within an elegant black‑toned interface. No external libraries are required—just HTML, CSS, and vanilla JavaScript.
Step 1: Set Up the Basic HTML Structure
Begin by creating an index.html file. Inside, we’ll lay out a minimal form with an input field for the date and a display area for the converted words. Use a clean semantic structure: a container div, a label, an input of type date, a button to trigger the conversion, and an empty paragraph where the result will appear. This foundation ensures accessibility and straightforward styling later. Keep everything wrapped in a main element to center the content vertically and horizontally.

Step 2: Craft the Black‑Toned CSS Theme
Next, define a stylesheet that embodies a sophisticated black tone. Use a dark background (#0f0f0f or #1a1a1a) with subtle grey borders and soft white text for high contrast. Apply a modern sans‑serif font like Inter or system UI. Style the input and button to match—dark inputs with glowing, muted accents, perhaps a deep teal or gold hover effect borrowed from peacock iridescence. Round the corners, add smooth transitions, and center everything using flexbox. The result should feel like a premium, midnight‑colored dashboard, keeping focus on the converted text.
![]()
Step 3: Write the Number‑to‑Words Logic
Now the core functionality. Create a JavaScript function that converts an integer into English words. Start by handling numbers from 0 to 19 individually, then tackle tens (twenty, thirty, etc.), and finally combine them for numbers up to 999. Use arrays for the base words and build the string recursively or with a straightforward if‑else chain. For the year part, special handling is needed: convert a four‑digit year into two two‑digit numbers (e.g., 1990 becomes “nineteen ninety”). This step demands careful testing with edge cases like 2000 (“two thousand”) or 1905 (“nineteen oh five”).

Step 4: Parse the Date Input and Assemble the Sentence
With the word converter ready, extract the date of birth from the input. When the user clicks the convert button, retrieve the value (YYYY‑MM‑DD). Split it into year, month, and day. Map the numeric month (0‑based) to the month name array (“January”, “February”, …). Convert the day integer to words, then the year using the special two‑part conversion. Finally, stitch them together: “[Month] [day‑in‑words], [year‑in‑words]”. Add an ordinal suffix to the day if you prefer, like “twenty‑fifth” instead of “twenty‑five”. Display the assembled string in the result paragraph, and handle invalid or empty inputs gracefully.

Step 5: Enhance the User Experience with Live Feedback
Beyond the basic button click, make the tool more responsive by adding a live preview that updates as the date input changes. Attach an event listener to the input’s change event and call the conversion function immediately. Also, introduce subtle animations: fade in the result text, pulse the button on click, or add a shimmer effect to the output using CSS keyframes. You can even let users copy the result with a single click. These finishing touches turn a utilitarian converter into a delightful micro‑interaction, all while maintaining the sleek black, peacock‑inspired aesthetic.












