Using Javascript to format dates
Date masks to try:
Mask format key
- d - day part with no leading zero
- dd - day part with leading zero
- m - month part with no leading zero
- mm - month part with leading zero
- mmm - month abbreviation (e.g. Oct)
- mmmm - month name (e.g October)
- yy - 2-digit year
- yyyy - 4-digit year
Notes
It seems pretty obviousin hindsight that the better way would be to extend the Javascript date object, so that we could just call dateObj.format("dd-mmm-yyyy"). Live and learn--a task for another day.
Function List
- array getMonthNameArray() - returns array of month names
- array getMonthAbbrArray() - returns array of month abbreviations
- int getDaysInMonth(date object) - returns number of days in month (including 29 for Feb in leap years)
- bool isLeapYear(date object) - returns whether or not the date specified is in a leap year
- Date prevMonth(date object) - returns date object one month back
- Date nextMonth(date object) - returns date object one month ahead
- str dayFormat(d number,mask string) - returns formatted day-of-month string
- str monthFormat(m number,mask string) - returns formatted month string
- str yearFormat(y number,mask string) - returns formatted year string
- str dateFormat(date object,mask string) - returns formatted date string