Latest web development tutorials

JavaScript toTimeString () method

Date Object Reference JavaScript Date Object

Examples

The time portion of the Date object is converted to a string:

var d=new Date();
var n=d.toTimeString();

n output:


try it"

Definition and Usage

toTimeString () method of the time part of a Date object converted to a string and returns the result.


Browser Support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

All major browsers support toTimeString () method


grammar

Date.toTimeString()


Return Value

Type 描述
String 时间作为字符串输出


Date Object Reference JavaScript Date Object