Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

JavaScript toLocaleTimeString() Method

JavaScript toLocaleTimeString() Method

Date Object Reference JavaScript Date object

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

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 a Date object, expressed in the local time zone and formatted according to local conventions.

Technical Details

JavaScript version: 1.0

Date Object Reference JavaScript Date object