JavaScript Date.prototype.toLocaleTimeString() Method
The toLocaleTimeString() method formats the time part of a Date for a given language and region.
Description
The toLocaleTimeString() method returns the time part of the date formatted for a locale, including the choice of 12- or 24-hour clock. Pass { hour: '2-digit', minute: '2-digit' } to leave out the seconds, and timeZone to show the time in another zone.
The hour12 option forces a 12- or 24-hour clock regardless of the locale's usual choice, and timeZoneName: 'short' adds an abbreviation such as "ACDT". As with dates, reuse an Intl.DateTimeFormat when formatting many times.
For showing both the date and the time together, toLocaleString() combines them, and the dateStyle and timeStyle options give consistent preset formats.
Syntax
date.toLocaleTimeString()
date.toLocaleTimeString(locales, options)Parameters
- localesOptional. A language tag.
- optionsOptional. Options such as
hour,minute,hour12andtimeZone.
Return Value
A string with the time part formatted for the language.
Example
Browser Support
The following information will show you the current browser support for the Date.prototype.toLocaleTimeString() method. Hover over a browser icon to see the version that first introduced support for this method.
Desktop





Tablets & Mobile





