JavaScript toLocaleTimeString() Method
Example
Converts the time portion of a Date object to a string based on local time:
var d=new Date();
var n=d.toLocaleTimeString();
n Output result:
Try it »
Definition and Usage
The toLocaleTimeString() method converts the time portion of a Date object to a string based on local time and returns the result.
Browser support





All major browsers support the toLocaleTimeString() method
Syntax
Date
.toLocaleTimeString()
Return Value
| Type | Description |
|---|---|
| String | A string representation of the time portion of a Date object, expressed in the local time zone and formatted according to local conventions. |
Technical Details
| JavaScript version: | 1.0 |
|---|
JavaScript Date object