toString
Summary
Returns a human readbale string representation of a date.
Syntax
toString()
Return Value
String that contains the date, time and timezone in a human readable format.
Examples
var now = new Date();
console.log(now.toString());
// outputs: "Wed Oct 08 2014 13:46:37 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 Wed Oct 08 2014 13:46:37 GMT+0200 (CEST)
.
toString() 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
- toDateString Method (Date)
- toGMTString Method (Date)
- toISOString Method (Date)
- toLocaleString Method (Date)
- toLocaleDateString Method (Date)
- toLocaleTimeString Method (Date)
- toTimeString Method (Date)
- toUTCString Method (Date)
External resources
Specification
ECMAScript® Language Specification Standard ECMA-262 5.1 Edition / June 2011
Attributions
Microsoft Developer Network: Article