Hi,
A feature I am using in Editor widget has a DateTime attribute
By default the Date/Time fields are in the format of: mm/dd/yyyy
Instead, I need it to be: dd/mm/yyyy
I do not know how to do this change.
But preferably, when the user clicks the date field a calendar should appear to select a day.
Any help would be greatly appreciated.
Thanks!
Solved! Go to Solution.
Hi, thanks for asking about this. Unfortunately, there is no direct and easy way to set this right now in the FeatureForm (and hence the Editor since this uses the FeatureForm widget). We are actively working on making this easier for all widgets that make use of dates and will hopefully have a better way to handle this in an upcoming release.
For now, formatting for dates in the FeatureForm is taken directly by the browser. If you're browser's locale was set to "en-GB", the format would flip to dd/mm/yyyy. I realize that this is not the answer you were looking to get. We do hope to make this easier in the near future.
Hi, thanks for asking about this. Unfortunately, there is no direct and easy way to set this right now in the FeatureForm (and hence the Editor since this uses the FeatureForm widget). We are actively working on making this easier for all widgets that make use of dates and will hopefully have a better way to handle this in an upcoming release.
For now, formatting for dates in the FeatureForm is taken directly by the browser. If you're browser's locale was set to "en-GB", the format would flip to dd/mm/yyyy. I realize that this is not the answer you were looking to get. We do hope to make this easier in the near future.
Thanks for the response @HeatherGonzago, appreciated.
Unfortunately, there is no direct and easy way to set this right now
As a non-direct way, perhaps:
Could I ask you if you can think of a better approach?
Hi,
We followed your advice and set the language to Danish. That worked, and the format switched to dd/mm/yyyy. At that time, the ArcGIS Maps SDK for JavaScript version was 4.24. However, after we updated to ArcGIS Maps SDK for JavaScript v. 4.31, the format has switched back to mm/dd/yyyy, even though the browser setting remains unchanged. Is there anything we can do to restore the dd/mm/yyyy format?
Hi @JohnZachariassen I wonder if you are seeing a slight update that was made for localization in 4.31? The SDK will automatically use the locale defined via the lang attribute on the root html element, or the locale of the browser. Do you have the locale defined on the root html element? Another thing to try, is to set the locale using intl.setLocale(). This should take care of it if it is not automatically getting picked up by the browser. Take a look at https://developers.arcgis.com/javascript/latest/localization/ for additional info on it. If it still doesn't work, let us know.
@Hi @HeatherGonzago.
We modified the code by using intl.setLocale(), and now the date format is as we wanted. Thank you for the helpful answer; it is greatly appreciated!
Great, glad to hear it's working out. Thanks for letting us know.