Skip to main content

dateFormat

Description

Optional. Defines the format of dates in the spreadsheet

Usage

dateFormat?: string;

Default config

dateFormat: "%d/%m/%Y"

Example

const spreadsheet = new dhx.Spreadsheet("spreadsheet", {
dateFormat: "%D/%M/%Y",
// other config parameters
});

spreadsheet.parse({
styles: {
// a set of styles
},
data: [
{cell: "B1", value: "03/10/2022", format: "date"},
{cell: "B2", value: new Date(), format: "date"},
]
});

List of characters

DHTMLX Spreadsheet uses the following characters for setting a date format:

CharacterDefinition
%dday as a number with leading zero, 01..31
%jday as a number, 1..31
%Dshort name of the day, Su Mo Tu...
%lfull name of the day, Sunday Monday Tuesday...
%mmonth as a number with leading zero, 01..12
%nmonth as a number, 1..12
%Mshort name of the month, Jan Feb Mar...
%Ffull name of the month, January February March...
%yyear as a number, 2 digits
%Yyear as a number, 4 digits
%hhours 12-format with leading zero, 01..12)
%ghours 12-format, 1..12)
%Hhours 24-format with leading zero, 00..23
%Ghours 24-format, 0..23
%iminutes with leading zero, 01..59
%sseconds with leading zero, 01..59
%aam or pm
%AAM or PM
%umilliseconds

Change log:

  • From v4.3, it is possible to set the date as a new Date() object in the data set
  • Added in v4.2

Related articles: Date format