Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

JavaScript toLocaleDateString() Method

JavaScript toLocaleDateString() Method

Date Object Reference JavaScript Date object

Example

Converts the date portion of a Date object to a string based on local time:

var d=new Date();

var n=d.toLocaleDateString();

n Output result:

Try it »


Definition and Usage

The toLocaleDateString() method converts the date portion of a Date object to a string based on local time and returns the result.


Browser support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

All major browsers support the toLocaleDateString() method


Syntax

Date

.toLocaleDateString()

Return Value

Type Description
String A string representation of the date portion of a Date object, expressed in the local time zone and formatted according to local conventions.

Technical Details

JavaScript version: 1.0

Date Object Reference JavaScript Date object