Javascript - Date toLocaleTimeString() Method

The toLocaleTimeString() method returns the time part of a Date object as a string, using locale conventions.

Description

The toLocaleTimeString() method returns the time part of a Date object as a string, using locale conventions.

Syntax

Date.toLocaleTimeString()

Return

A String, representing the time as a string

Example

Return the time portion of a Date object as a string, using locale conventions:

Demo

//display the time as a string.

var d = new Date();
var n = d.toLocaleTimeString();
console.log(n);/*www.  j a  v  a2 s .  c  o m*/

Result