O'Reilly logo

jQuery and JavaScript Phrasebook by Brad Dayley

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required