This page is Almost Ready

Notice: The WebPlatform project, supported by various stewards between 2012 and 2015, has been discontinued. This site is now available on github.

toTimeString

Summary

Returns the time component of a date as a human readable string.

Syntax

toTimeString()

Return Value

String value containing the time, in the current time zone, in a convenient, human readable format, e.g. 15:20:46 GMT+0200 (CEST)

Examples

var date = new Date();
console.log(date.toTimeString());
// outputs: "15:20:46 GMT+0200 (CEST)"
console.log(now.toString());
// outputs: "Wed Oct 08 2014 15:20:46 GMT+0200 (CEST)"

Notes

According to the specification the contents of the String are implementation-dependent. That means that you cannot rely on the returned format being consistent across browsers. That said, all major browsers seem to agree on the format 15:20:46 GMT+0200 (CEST)

toTimeString() adds the code of the current timezone to the output. Because the output format is not specified, some browsers might replace (CEST) (Central European Summer Time) with a fully localized text, e.g. the German (Mitteleuropäische Sommerzeit).

See also

Other articles

External resources

Specification

Date.prototype.toTimeString()

ECMAScript® Language Specification Standard ECMA-262 5.1 Edition / June 2011

Attributions

  • Microsoft Developer Network: Article