Javascript - Date toTimeString() Method

The toTimeString() method converts the time portion of a Date object to a string.

Description

The toTimeString() method converts the time portion of a Date object to a string.

Syntax

Date.toTimeString()

Return Value

A String, representing the time as a string

Example

Convert the time portion of a Date object to a string:

Demo

//display the time as a string.
var d = new Date();
var n = d.toTimeString();
console.log(n);/*from w w w  . ja va2s .c  om*/

Result