how can I define global default date format in flexmonster

Answered
amir asked on December 31, 2021

Has there been any update that enables me to set the global default date format for flexmonster? Currently, for tables, I am setting date format (mm/dd/yyyy) but for charts, for some reasons I cannot individually set date format for each chart so it is rendered in flexmonster default format (dd/mm/yyyy). How can I set a global date format that is used everywhere in flexmonster. 

3 answers

Public
Nadia Khodakivska Nadia Khodakivska Flexmonster December 31, 2021

Hello, Amir,
 
Thank you for writing to us.
 
To display the same default date format for both grid and charts, you should set the necessary format in the GlobalObject: https://www.flexmonster.com/doc/global-options/.
Kindly check the example on the following JSFiddle: https://jsfiddle.net/flexmonster/2v08rz1u/
 
Please let us know if it works for you. Feel free to contact us if other questions arise.
 
Kind regards,
Nadia

Public
amir January 5, 2022

Thank you for the reply, Nadia, can we somehow set the date format default to user locale i.e, automatically pick date format as per user locale. The same way we get using javascript Date.toLocaleString() function

Public
Nadia Khodakivska Nadia Khodakivska Flexmonster January 6, 2022

Hello, Amir,
 
Thank you for the response.
 
To set the date format default to user locale, you need to:

  1. get the needed date format in your JavaScript code,
  2. create the datePattern based on the format from step 1 (note that Flexmonster supports the following date formats: https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-daterange-aggregation.html#date-format-pattern ),
  3. set the datePattern when initializing Flexmonster.

Hope it helps!
 
Kind regards,
Nadia

Please login or Register to Submit Answer