How To: Add AM or PM in a web map pop-up
Date and time values can be included in a web map pop-up. However by default, the time (which displays in a 12-hour time format) does not include AM or PM indicators. This may be confusing for viewers when trying to determine in which half of the day an event occurred.
The image below shows a pop-up in the Portal for ArcGIS Map Viewer where time is displayed without AM or PM.
AM or PM indicators can be included using an Arcade expression. This is possible using ArcGIS Arcade Text Functions to specify the desired format for dates and time to be displayed in the pop-up.
The following steps describe how to add the Arcade expression to the pop-up in a web map:
- Configure pop-ups in ArcGIS Online or a web map.
- In the Configure Pop-up side console, scroll to Attribute Expressions and click ADD.
- Type the expression in the Attribute Expression text box and click OK to execute the expression.
The following is the Arcade expression used to add AM or PM in the web map pop-up. If the hour is more than 12, PM is returned, or else, AM is returned.
var n = Date(2018,04,24,05,09); Text(n,'M/DD/YY, hh:mm A')
The following image shows AM added at the end of the time in the web map pop-up according to the steps above.