HOW TO
At times, it is necessary to convert the 24-hour time format string values to the 12-hour format (AM or PM). However, it is time-consuming if the data provided is large, as shown in the image below. This is resolved by using an Arcade expression to populate the data in the attribute table. This article provides the steps to convert the 24-hour time format string values to a 12-hour format using an Arcade expression in Portal for ArcGIS and ArcGIS Online Map Viewer.
Note:
This workflow only applies to time data in a text field. For time data in a date field, use the Convert Time Field (Data Management) tool in ArcGIS Pro to convert the date field to a text field.
var t = ($feature.<TIME_FIELD>) var h = Number(Split(t, ":", 2)[0]); var m = Split(t, ":", 2)[1]; var AMPM = When( h > 12, h - 12, h == 0, 12, h ); var suffix = When( h == 24, " AM", h >= 12, " PM", " AM" ); Concatenate( [ AMPM, m ], ":" ) + suffix;
The image below shows the time in the 12-hour time format in the attribute table in Portal for ArcGIS.
Article ID: 000031184
Get help from ArcGIS experts
Download the Esri Support App