Flexmonster Software License Agreement (“Agreement”) has been revised and is effective as of September 30, 2025.
The following modifications were made:
The modified version of Agreement is available here.
Downloading, installing, and/or continuing to use Flexmonster Software after September 30, 2025, constitutes Licensee’s acceptance of the terms and conditions of the modified version of Agreement. If Licensee does not agree to any of these terms and conditions, they must cease using Flexmonster Software and must not download, install, use, access, or continue to access Flexmonster Software. By continuing to use Flexmonster Software or renewing the license or maintenance after the effective date of these modifications to Agreement, Licensee accepts and agrees to be bound by the terms and conditions of the modified Agreement.
This tutorial explains how to format date and time fields when using JSON, CSV, Flexmonster Data Server, MongoDB, and the custom data source API. If using another data source:
Note Learn about input date formats that Flexmonster supports for JSON, CSV, Flexmonster Data Server (JSON and CSV), and the custom data source API.
By default, date fields have the "date" type for JSON and CSV, and the "date string" type for Flexmonster Data Server, MongoDB, and the custom data source API.
You can override the default date type for all date fields in the dataset (supported only for JSON and CSV) or for specific fields. If you want to apply formatting to date fields, use the following types:
Learn more about available date types in our video overview:
To change the default type for all date fields, use the options.defaultDateType property:
report: {
options: {
defaultDateType: "date string"
}
}The "date string" type will now be applied to all date fields in the dataset
Live example. Check out all available date types.
Note The defaultDateType option works only for "json" and "csv" data source types.
To change the default type for a specific date field, use the mapping. Learn how to define the type of a field in the mapping.
Check out all available date types.
In Flexmonster, "date string" and "datetime" fields are formatted using pattern strings. Formatting can be applied to all fields of a specific date type or to each field separately.
To format fields of the "date string" type, use the options.datePattern property, and to format fields of the "datetime" type, use the options.dateTimePattern property:
report: {
options: {
datePattern: "yyyy.MM.dd",
dateTimePattern: "yyyy.MM.dd HH:mm TT"
},
dataSource: {
data: [
// ...
],
mapping: {
"Date1": {
type: "date string"
},
"Date2": {
type: "datetime"
}
}
}
}To format a specific field of the "date string" or "datetime" type, use the format property in the mapping. The format overrides other formatting options, such as datePattern and dateTimePattern.
Here is an example of how to define formatting for a certain field:
report: {
options: {
dateTimePattern: "MMM d, yyyy, h:mm:ss TT",
// ...
},
dataSource: {
data: [
// ...
],
mapping: {
"OrderDateTime": {
type: "datetime",
format: "GMT+6:dd/MM/yyyy HH:mm:ss",
}
}
}
}In the example above, dateTimePattern is ignored for the OrderDateTime field because the format property in the mapping overrides the format from options.
See the list of the supported patterns for "date string" and "datetime" fields:
| Pattern | Meaning | Pattern value displayed as |
|---|---|---|
d | Day of the month | A one- or two-digit number. For example, 2 or 18. |
dd | Day of the month | A two-digit number. For example, 02 or 18. |
ddd | Day of the week | A three-letter abbreviation of the day of the week. For example, Wed. |
dddd | Day of the week | The full name of the day of the week. For example, Wednesday. |
M | Month | A one- or two-digit number. For example, 3 or 11. |
MM | Month | A two-digit number. For example, 03. |
MMM | Month | A three-letter abbreviation of the name of the month. For example, Mar. |
MMMM | Month | The full name of the month. For example, March. |
yy | Year | A two-digit number. For example, 16. |
yyyy | Year | A four-digit number. For example, 2016. |
h | Hour of the day using the 12-hour format [1 – 12] | A one- or two-digit number. For example, 1 or 12. |
hh | Hour of the day using the 12-hour format [1 – 12] | A two-digit number. For example, 01 or 12. |
H | Hour of the day using the 24-hour format [0 – 23] | A one- or two-digit number. For example, 0 or 23. |
HH | Hour of the day using the 24-hour format [0 – 23] | A two-digit number. For example, 00 or 23. |
k | Hour of the day using the 24-hour format [1 – 24] | A one- or two-digit number. For example, 1 or 24. |
kk | Hour of the day using the 24-hour format [1 – 24] | A two-digit number. For example, 01 or 24. |
m | Minutes [0 – 59] | A one- or two-digit number. For example, 0 or 59. |
mm | Minutes [0 – 59] | A two-digit number. For example, 00 or 59. |
s | Seconds [0 – 59] | A one- or two-digit number. For example, 0 or 59. |
ss | Seconds [0 – 59] | A two-digit number. For example, 00 or 59. |
t | am/pm | A one-letter indicator. For example, a or p. |
tt | am/pm | A two-letter indicator. For example, am or pm. |
T | AM/PM | A one-letter indicator. For example, A or P. |
TT | AM/PM | A two-letter indicator. For example, AM or PM. |
UTC: | UTC Time zone | Indicates that the UTC time zone should be used. Example format: "UTC:dd/MM/yyyy HH:mm:ss". |
GMT+-N: | Time zone | Indicates the time zone to use, where N can be changed from 1 to 12. Example format: "GMT+6:dd/MM/yyyy HH:mm:ss". |
Examples of "date string" and "datetime" formats:
| Pattern | Example of a formatted date |
|---|---|
"yyyy-MM-dd" | 2021-04-25 |
"M/d/yy" | 4/25/21 |
"MMM d, yyyy" | Mar 25, 2021 |
"MMMM d, yyyy" | March 25, 2021 |
"dddd, MMMM d, yyyy" | Sunday, March 25, 2021 |
"M/d/yy, h:mm TT" | 4/25/21, 9:30 PM |
"MMM d, yyyy, h:mm:ss TT" | Mar 25, 2021, 9:30:00 PM |
"h:mm TT" | 9:30 PM |
"h:mm:ss TT" | 9:30:05 PM |
Note For JSON and CSV data sources, "date string" fields are rounded down with the "1d" interval by default (e.g., "04/25/2021T21:30:05" is rounded down to "04/25/2021T00:00:00"). See how to change the interval.
By default, Flexmonster uses the user’s local time zone for dates.
For example, your dataset contains a date with the GMT+2 time zone: "2021-04-25T21:30:05+02:00". Flexmonster will display this date according to your local time zone
Live example.
If needed, you can set another time zone:
Note Setting a time zone in the component affects only date representation; the original data is not changed.
To set a timezone for all date fields, use the options.dateTimezoneOffset property. The dateTimezoneOffset represents the difference in hours between the needed time zone and UTC.
For example, the GMT-5 time zone can be set like this:
report: {
options: {
dateTimezoneOffset: -5
},
dataSource: {
// ...
}
}For "date string" and "datetime" fields, you can set a time zone right in the datePattern and dateTimePattern options.
To set a time zone, include "GMT+-N:" at the beginning of the pattern (e.g., "GMT+6:dd/MM/yyyy"). N should be changed from 1 to 12. Check out an example for the datePattern and the dateTimePattern.
Note Time zone set in the format patterns will override a time zone set for all fields.
For all other date types, set the dateTimezoneOffset option.
To set a time zone for a specific "date string" or "datetime" field, include "GMT+-N:" at the beginning of the pattern set in the format mapping property. N should be changed from 1 to 12.
Time zone set in the format will override time zone configurations for all fields and for fields of a specific type.
Example:
report: {
options: {
dateTimezoneOffset: +5
},
dataSource: {
data: [
// ...
],
mapping: {
"OrderDateTime": {
type: "datetime",
format: "GMT+6:dd/MM/yyyy HH:mm:ss",
}
}
}
}In the example above, dateTimezoneOffset is ignored for the "OrderDateTime" field because the format property in the mapping overrides the time zone.
Dates in Flexmonster can be rounded down with the mapping.interval property. Use this feature to group dates by a certain interval on the pivot table.
In the code snippet below, all dates have the same day part, but different time parts. The "1d" interval will round all dates to 2021-04-25T00:00:00:
report: {
dataSource: {
data: [{
"DeliveryDate": "2021-04-25T21:30:05",
"Price": 200
},
{
"DeliveryDate": "2021-04-25T23:55:00",
"Price": 150
}
],
mapping: {
"Date": {
interval: "1d",
type: "datetime"
}
}
}
}Note For "json" and "csv" data source types, "date string" fields are rounded down with the "1d" interval by default. If you want to display the actual time instead of 00:00:00, specify a smaller interval in the mapping (e.g., with the "1h" interval value, "04/25/2021T21:30:05" is rounded down to "04/25/2021T21:00:00").
In Flexmonster, time fields are formatted using pattern strings. Formatting can be applied to all time fields or to each field separately.
To format all fields of the "time" type, use the options.timePattern property:
report: {
options: {
timePattern: "d'd' HH'h' mm'min'"
},
dataSource: {
data: [
// ...
],
mapping: {
"Time": {
type: "time"
}
}
}
}To format a specific time field, use the format property in the mapping. The format overrides the options.timePattern property.
Here is an example of how to define formatting for a certain field:
report: {
dataSource: {
data: [
// ...
],
mapping: {
"Duration": {
type: "time",
format: "d'd' HH'h' mm'min'",
}
}
}
}See the list of the supported patterns for "time" fields below:
| Pattern | Meaning | Pattern value displayed as |
|---|---|---|
d | Days | A one- or two-digit number. For example, 5 or 11. |
dd | Days | A two-digit number. For example, 05 or 11. |
H | Hours | A one- or two-digit number. For example, 6 or 15. |
HH | Hours | A two-digit number. For example, 06 or 15. |
HHH | Hours | Time data in hours, even when the number of hours is greater than 24. For example, 46 or 15. |
m | Minutes | A one- or two-digit number. For example, 2 or 10. |
mm | Minutes | A two-digit number. For example, 02 or 10. |
s | Seconds | A one- or two-digit number. For example, 3 or 16. |
ss | Seconds | A two-digit number. For example, 03 or 16. |
Examples of time formats:
| Pattern | Example of a formatted date |
|---|---|
"HH:mm:ss" | 21:30:00 |
"d'd' HH'h' mm'min'" | 0d 21h 30min |