JavaScript toTimeString

The JavaScript toTimeString function returns the Time portion of a given date in a human-readable format, according to the local time zone. The syntax of the toTimeString Date function is:

 Date.toTimeString()

Return Value: It extracts and returns the time portion along with the time zone from the given date and time. If you pass an invalid date, the toTimeString() method returns an invalid date as output.

JavaScript toTimeString example

In the following example, we use the toTimeString function to return the time portion of today’s date and time as per the local system time zone.

const dt = new Date();
console.log(dt);
console.log(dt.toTimeString());
Tue Jun 16 2026 15:05:52 GMT+0530 (India Standard Time) 
15:05:52 GMT+0530 (India Standard Time)

TIP: Please use the toDateString() to extract the date portion or toString() for date and time.

Example 2: In this JavaScript example, the Date() constructor builds a custom date, and the toTimeString() method returns the string time of the custom datetime in a human-readable format.

const dt = new Date("January 1, 2023 12:45:30.555");
console.log(dt);
console.log(dt.toTimeString());
Sun Jan 01 2023 12:45:30 GMT+0530 (India Standard Time) 
12:45:30 GMT+0530 (India Standard Time)

Similar to the above, we used the Date() object to create a date from an integer number. Next, the toTimeString() extracts the time portion from it.

const dt = new Date(1947, 7, 15, 22, 15, 11);
console.log(dt);
console.log(dt.toTimeString());
Fri Aug 15 1947 22:15:11 GMT+0530 (India Standard Time) 
22:15:11 GMT+0530 (India Standard Time)

Example 3: If you use the toTimeString() method on a custom date without the time portion, it returns the local system time (difference between UTC and local time) as the output. As the local system is 5:30 hours ahead, it sets the time portion to 5:30.

const dt = new Date("2026-01-01");
console.log(dt);
console.log(dt.toTimeString());
Thu Jan 01 2026 05:30:00 GMT+0530 (India Standard Time) 
05:30:00 GMT+0530 (India Standard Time)