English

How To: Add AM or PM in a web map pop-up

Summary

Date and time values can be included in a web map pop-up. However by default, 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.

The date formatting does not add automatically the AM or PM at the end

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 the time and date to be displayed in the pop-up.

Procedure

The following steps describe how to add the Arcade expression to the pop-up in a web map:

  1. Configure pop-ups in ArcGIS Online or a web map.
  2. In the Configure Pop-up side console, scroll to Attribute Expressions and click ADD.
  1. 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);
var ampm = "";
if (Hour(n) > 12) {
ampm = "PM"
}
else {
ampm = "AM";
}
return Concatenate([Text(n,'ddd MMM D, h:m'), ampm], " ");

The following image shows AM added at the end of the time in the web map pop-up according to the steps above.

Related Information