ArcGIS JavaScript API 4.x Timeslider support 24 hour time format

1243
6
01-12-2022 01:47 PM
Status: Under Consideration
Labels (2)
KarlLarsen
New Contributor III

The ArcGIS JavaScript API 4.x supports a 12 hour AM/PM format on the timeslider today, however, many disciplines use 24 hour format, including Public Safety, Military and it is the primary time format for many parts of the world. Update the ArcGIS JavaScript API 4.x timeslider to support a 24 hour time format.

6 Comments
UndralBatsukh

Hi there, 

This can be done with TimeSlider by setting its labelFormatFunction and tickConfigs properties. This blog talks about how to set the tickConfigs property for TimeSlider. You can use Intl.DateTimeFormatter to format the dates and times you want to show on the TimeSlider.

I created this simple app shows how to format ticks and labels on the TimeSlider. Hope this helps. 

https://codepen.io/U_B_U/pen/YzrRgmK?editors=1000

 

KarlLarsen

Thanks Undral for the comment and references. We did look into this and for our use cases, we are still looking to retain the dynamic nature of the timeslider since we would also be looking at a longer time period in certain use cases. In one case we would be looking at data within an hour or two, others within a many hours and in another it may be a whole week. It seemed based on the feedback of a developer was that the approach here locks in the timeslider to a specified time extent. We would be looking for the dynamic nature to be retained and display hours in a 24 hour format when hours are shown based on full time extent. 

UndralBatsukh

Hi there, 

I have couple of questions to understand your requirements. 

1. Are you showing both dates and times along the TimeSlider ticks? Or just hours? 

2. Do you want to show 24 hours format only in TimeSlider or do you expect 24 hours format in any widget that shows date and time? Examples would be popup, FeatureTable and FeatureForm etc. If the latter is the case, then we can look into a global time setting where time will be displayed the same way in all widgets. 

KarlLarsen

Thanks for the follow up.

RE #1: we are just going with the dynamic out of the box behavior, so it will be minutes, hours, or days depending upon the full extent.

RE #2: yes, we would want to use 24 hour format globally in our application.

 

UndralBatsukh

Thanks for the quick reply. We added an enhancement request in our system to set a global formatting for time. I will update you once it is installed. In meantime, please use tickConfigs and labelFormatFunction to format time.  

UndralBatsukh
Status changed to: Under Consideration