Javascript - Date toLocaleString() Method

The toLocaleString() method converts a Date object to a string, using locale settings.

Description

The toLocaleString() method converts a Date object to a string, using locale settings.

Syntax

Date.toLocaleString()

Return

A String, representing the date and time as a string

Example

Convert a Date object to a string, using locale conventions:

Demo

//display the date and time as a string.
var d = new Date();
var n = d.toLocaleString();
console.log(n);//from   w ww .  ja  v  a 2s. c om

Result