Pre-poppulating dates with Date.js in MonthName, ##, #### format

120 views Asked by At

I have to pre-populate two calendars with values. I need it to be in the format of January 16, 2012. Currently, I am using Date.js (http://www.datejs.com/).

I currently have:

var e = Date.today(),
    s = Date.today().add(-30).days();

These return Mon Jan 16 2012 00:00:00 GMT-0500 (EST) which is of no use to me. Either using Date.js or not (I don't care), how do I get the current date in the format I'm asking for?

2

There are 2 answers

0
Jonathan Lonowski On BEST ANSWER

Date.js offers formatting with its custom toString method:

var eFormatted = e.toString('MMMM dd, yyyy');
    sFormatted = s.toString('MMMM dd, yyyy');

You can see the full list of format specifiers at http://code.google.com/p/datejs/wiki/FormatSpecifiers.

0
Liam On
Date.today().toString("mmmm dS, yyyy");

API Documentation: http://code.google.com/p/datejs/wiki/APIDocumentation