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

JavaScript toTimeString() Method

JavaScript toTimeString() Method

Date Object Reference JavaScript Date object

Example

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

var d=new Date();

var n=d.toTimeString();

n Output result:

Try it »


Definition and Usage

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


Browser support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

All major browsers support the toTimeString() method


Syntax

Date

.toTimeString()


Return Value

Type Description
String Time output as a string

Date Object Reference JavaScript Date object