JavaScript toLocaleTimeString()Method

Date 对象参考手册JavaScript Date Object

Example

Converts the time portion of a Date object to a string according to local time:

var d=new Date();
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

Internet ExplorerFirefoxOperaGoogle ChromeSafari

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


Date 对象参考手册JavaScript Date Object

Other Extensions