DHTMLX Docs & Samples Explorer

Formatting Date Values

Date formatting can be applied to dhxCalendar and dhxCalendarA columns.
Date formatting applied to the whole grid (so it will be used in any column of dhxCalendar type) can be set as:

grid.setDateFormat(mask)

Or in case of initialization from XML:

<column format="mask"...

Or when initialization is from HTML:

<td ... format="mask"...

Please, take into account that while it is possible to define a few formats with initialization from XML or HTML, only the last format will be applied.

Format string can contain any separator character and any element from the following list:

  • %d - day as number ( with leading zero );
  • %j - day as number;
  • %D - abbreviated name of the day;
  • %l - full name of the day;
  • %m - month as number ( with leading zero );
  • %n - month as number;
  • %M - abbreviated name of the month;
  • %F - full name of the month;
  • %y - year as number (2 digits);
  • %Y - year as number (4 digits);
  • %H - hours (24);
  • %i - minutes;

For example:

grid.setDateFormat("%m/%d/%Y");     // =>   01/25/1980
grid.setDateFormat("%d-%c-%y");      // =>   25-1-80
grid.setDateFormat("%M %e, %W");    // =>   January 25, Friday