Node.js Date Utils

Sunday, January 9, 2011 - Jerry Sievert

Introducing my first Github repository: node-date-utils. During redevelopment of my freezer daemon (more to come later), I found a couple of missing Date methods. This is an attempt to fill some of them in.

Github Repository


npm install date-utils

Including parsing ISO 8601, month names, and common log format date string:


// Sun Jan 09 2011 09:57:17 GMT-0800 (PST)
var date = new Date(Date.parse('2011-01-09T17:57:17.231Z'));

// Jan
var abbreviated_month = date.getMonthAbbr();

// January
var month = date.getMonthName();

// 09/Jan/2011:09:57:017 -0800
var clf = date.toCLString();