Creating a Date String

var d = new Date(); d.toDateString(); //Returns Sat May 17 2014 d.toLocaleDateString(); //Returns Saturday, May 17, 2014 d.toISOString(); //Returns 2014-05-17T19:55:13.000Z d.toUTCString(); //Returns Sat, 17 May 2014 19:55:13 GMT d.toString(); //Returns Sat May 17 2014 13:55:13 GMT-0600 (Mountain Daylight Time)

There are several methods to generate a date string from JavaScript. The first step is to get a Date object. The Date object provides the following methods that return differently formatted date strings:

Image .toDateString()—Returns an abbreviated date string.

.toLocaleDateString()—Returns ...

Get jQuery and JavaScript Phrasebook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.