HOW TO

Convert the 24-hour time format string values to the 12-hour time format in ArcGIS Pro

Last Published: October 7, 2024

Summary

In ArcGIS Pro, it is sometimes necessary to convert the 24-hour time format, or military time string values to the 12-hour time format (AM or PM).

This article provides two workflows to convert a string field containing time data in the 24-hour format to the 12-hour format.

Procedure

Use one of the workflows below to convert the 24-hour time format string values.

Use the Convert Temporal Field tool

Follow this workflow to convert the 24-hour time format string values and populate the result in a new field using the Convert Temporal Field tool.

  1. In ArcGIS Pro, on the Analysis tab, click Tools.
  2. In the Geoprocessing pane, search for and open the Convert Temporal Field (Data Management Tools) tool.
  3. Configure the parameters in the Convert Time Field pane.
    1. For Input Table, select the feature layer.
    2. For Input Field, select the string field containing the 24-hour format time data.
    3. For Input Format, type hh:mm.
    4. For Output Field Type, select Text.
    5. For Output Format, type h:m tt.
    6. Click Run.

The converted time strings are populated in the new field, 'timefield_Converted'.

The attribute table view of the feature layer containing the original string values and the converted 12-hour time format string values.

Use Arcade to convert the 24-hour time format in pop-ups

Follow this workflow to display the 24-hour time format in the 12-hour time format in pop-ups without creating a new field.

  1. In ArcGIS Pro, in the Content pane, right-click the feature layer, and click Configure Pop-ups.
  2. In the Configure Pop-ups pane, click Expressions.
  3. Click New.
  4. In the Expression Builder dialog box, configure the following parameters.
    1. For Title, specify a title for the expression. In this example, the title is 'AM/PM'.
    2. For Expression, configure the following Arcade expression. Replace <time_field_name> with the name of the string field containing the 24-hour time format data.
// This value should be a string.
// e.g. `13:00`, `22:36`, `00:45`

var eventTime = $feature.<time_field_name>;

var oriHours = Number(Split(eventTime, ":", 2)[0]);
var minutes = Split(eventTime, ":", 2)[1];
var AMPM = When( 
  oriHours > 12, oriHours - 12,
  oriHours == 0, 12,
oriHours );
var suffix = When(
  oriHours == 24, " AM",
  oriHours >= 12, " PM",
" AM" );
Concatenate( [ AMPM, minutes ], ":" ) + suffix;
  1. Click OK.
  2. In the Configure Pop-ups pane, click Back The Back icon symbolized by an arrow pointing to the left..

The time is displayed in the 12-hour time format in the pop-up.

A pop-up displaying the converted 12-hour time format string value.

Article ID: 000028951

Software:
  • ArcGIS Pro 3 0
  • ArcGIS Pro 2 x

Receive notifications and find solutions for new or common issues

Get summarized answers and video solutions from our new AI chatbot.

Download the Esri Support App

Related Information

Discover more on this topic

Get help from ArcGIS experts

Contact technical support

Download the Esri Support App

Go to download options