3 A node.js package for Steven Levithan's excellent [dateFormat()][dateformat] function.
5 [![Build Status](https://travis-ci.org/felixge/node-dateformat.svg)](https://travis-ci.org/felixge/node-dateformat)
9 * Removed the `Date.prototype.format` method. Sorry folks, but extending native prototypes is for suckers.
10 * Added a `module.exports = dateFormat;` statement at the bottom
11 * Added the placeholder `N` to get the ISO 8601 numeric representation of the day of the week
16 $ npm install dateformat
22 As taken from Steven's post, modified to match the Modifications listed above:
24 var dateFormat = require('dateformat');
28 dateFormat(now, "dddd, mmmm dS, yyyy, h:MM:ss TT");
29 // Saturday, June 9th, 2007, 5:46:21 PM
31 // You can use one of several named masks
32 dateFormat(now, "isoDateTime");
33 // 2007-06-09T17:46:21
36 dateFormat.masks.hammerTime = 'HH:MM! "Can\'t touch this!"';
37 dateFormat(now, "hammerTime");
38 // 17:46! Can't touch this!
40 // When using the standalone dateFormat function,
41 // you can also provide the date as a string
42 dateFormat("Jun 9 2007", "fullDate");
43 // Saturday, June 9, 2007
45 // Note that if you don't include the mask argument,
46 // dateFormat.masks.default is used
48 // Sat Jun 09 2007 17:46:21
50 // And if you don't include the date argument,
51 // the current date and time is used
53 // Sat Jun 09 2007 17:46:22
55 // You can also skip the date argument (as long as your mask doesn't
56 // contain any numbers), in which case the current date/time is used
57 dateFormat("longTime");
60 // And finally, you can convert local time to UTC time. Simply pass in
61 // true as an additional argument (no argument skipping allowed in this case):
62 dateFormat(now, "longTime", true);
65 // ...Or add the prefix "UTC:" or "GMT:" to your mask.
66 dateFormat(now, "UTC:h:MM:ss TT Z");
69 // You can also get the ISO 8601 week of the year:
73 // and also get the ISO 8601 numeric representation of the day of the week:
79 (c) 2007-2009 Steven Levithan [stevenlevithan.com][stevenlevithan], MIT license.
81 [dateformat]: http://blog.stevenlevithan.com/archives/date-time-format
82 [stevenlevithan]: http://stevenlevithan.com/