JavaScript toLocaleTimeString()Method
Example
Converts the time portion of a Date object to a string according to local time:
var d=new Date();
var n=d.toLocaleTimeString();
var n=d.toLocaleTimeString();
nOutput:
Try it yourself »
Definition and Usage
The toLocaleTimeString() method converts the time portion of a Date object to a string according to 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 the date Object, expressed in the local time zone and formatted according to local rules. |
Technical Details
| JavaScript Version: | 1.0 |
|---|
Other Extensions
JavaScript Date Object