DHTMLX Docs & Samples Explorer

Index
dhtmlxgrid

## 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.

The mask can contain the following special markers:

      %e    Day of the month without leading zeros (01..31)
      %d    Day of the month, 2 digits with leading zeros (01..31)
      %j     Day of the year, 3 digits with leading zeros (001..366)
      %a    A textual representation of a day, three letters
      %W   A full textual representation of the day of the week

      %c    Numeric representation of a month, without leading zeros (0..12)
      %m   Numeric representation of a month, with leading zeros (00..12)
      %b    A short textual representation of a month, three letters (Jan..Dec)
      %M   A full textual representation of a month, such as January or March (January..December)

      %y    A two digit representation of a year (93..03)
      %Y    A full numeric representation of a year, 4 digits (1993..03)

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