Example 1 — Format Local Clock Time
Call toTimeString() on a fixed local date-time.
const event = new Date(1975, 7, 19, 23, 15, 30); // Aug 19, 1975
console.log(event.toTimeString());
// e.g. "23:15:30 GMT+0530 (India Standard Time)" How It Works
- Build a local date. Month index
7is August; time is 23:15:30. - Format the time.
toTimeString()reads local hours, minutes, and seconds. - Append offset. The engine adds
GMT±xxxxand usually a timezone name. - No date. The calendar day is omitted — that is what makes it “time string.”

