JavaScript toTimeString(): Convert a Date to Time Text

Date.prototype.toTimeString() returns the time portion of a Date as a string interpreted in the local time zone. The text normally includes local hours, minutes, seconds, the numeric UTC offset and a time-zone description.

Syntax:

date.toTimeString();

Example:

const date = new Date(2026, 8, 10, 18, 45, 30);
console.log(date.toTimeString());

What toTimeString() Returns Top ↑

The return value is a string. Unlike toString(), it omits the calendar-date portion.

const date = new Date();
const text = date.toTimeString();
console.log(text);
console.log(typeof text); // "string"

Local Time-Zone Behavior Top ↑

The same timestamp can produce different toTimeString() values in different local time zones because the method formats the Date using the host’s local zone.

toTimeString() vs toLocaleTimeString() Top ↑

toTimeString() gives a general local time representation with no formatting arguments. toLocaleTimeString() is better when the time should follow a locale or custom display options.

const date = new Date();
console.log(date.toTimeString());
console.log(date.toLocaleTimeString("en-IN", { hour: "2-digit", minute: "2-digit" }));

Comparing Local Time with UTC Top ↑

For a UTC text representation, toUTCString() includes the full UTC date and time. For standardized machine output, toISOString() is often more useful.

const date = new Date();
console.log(date.toTimeString()); // local
console.log(date.toUTCString()); // UTC date + time
console.log(date.toISOString()); // standardized UTC

Getting Numeric Time Components Top ↑

If you need to calculate with hours, minutes or seconds, use Date getters instead of parsing toTimeString().

const date = new Date();
const hours = date.getHours();
const minutes = date.getMinutes();
const seconds = date.getSeconds();
console.log(hours, minutes, seconds);

When Not to Use toTimeString() Top ↑

Do not save or transmit this display string as your time data. Keep the Date/timestamp or a defined ISO representation and format it only for presentation.

Common toTimeString() Mistakes Top ↑

  • Assuming the method displays UTC.
  • Expecting localized 12/24-hour formatting options.
  • Parsing numeric time fields out of the returned text instead of using getters.
  • Using the string as a stable API or storage format.

Next: UTC Date Methods Date Reference




Subscribe to our YouTube Channel here



plus2net.com










✖
We use cookies to improve your browsing experience. . Learn more
HTML MySQL PHP JavaScript ASP Photoshop Articles Contact us
© 2000-2026 plus2net.com All rights reserved worldwide Privacy Policy Disclaimer