toLocaleString (Date - JavaScript)

Gets a string representation of the Date object taking into account the host locale.

Defined in

Date (Standard - JavaScript)

Syntax

toLocaleString() : string
Return value Description
string The string representation of the Date object.

Examples

(1) This computed label displays the current date and time.
var date = new Date();
date.toLocaleString()
// Nov 26, 2006 11:25:36 AM

(2) This computed label displays the base date and time (where the time zone is -5).

var date = new Date(0);
date.toLocaleString()
// Dec 31, 1969 7:00:00 PM