W3Schools.com

JavaScript toLocaleDateString() Method

Date Object Reference JavaScript Date Object

Definition and Usage

The toLocaleDateString() method returns the date portion of a Date object as a string, using locale conventions.

Syntax

Date.toLocaleDateString()


Browser Support

Internet Explorer Firefox Opera Google Chrome Safari

The toLocaleDateString() method is supported in all major browsers.


Example

Example

Return the date portion of a Date object as a string, using locale conventions:

<script type="text/javascript">

var d=new Date();
document.write("Original form: ");
document.write(d + "<br />");
document.write("Formatted form: ");
document.write(d.toLocaleDateString());

</script>

The output of the code above will be:


Try it yourself »


Date Object Reference JavaScript Date Object
WEB HOSTING
Best Web Hosting
PHP MySQL Hosting
Best Hosting Coupons
UK Reseller Hosting
Cloud Hosting
Top Web Hosting
$7.95/mo SEO Hosting
Premium Website Design
WEB BUILDING
Download XML Editor
FREE Website BUILDER
Free Website Templates Free CSS Templates
Make Your Own Website
W3SCHOOLS EXAMS
Get Certified in:
HTML, CSS, JavaScript, XML, PHP, and ASP
W3SCHOOLS BOOKS
New Books:
HTML, CSS
JavaScript, and Ajax
STATISTICS
Browser Statistics
Browser OS
Browser Display
SHARE THIS PAGE