Converting military time (24hr) to standard time (12hr)

How would I be able to convert military time to standard time by using a list of all military times (0-24), and incorporating sequence, selection, and repetition.

what the military time looks like? to change to what kind/format? better to have some demo here.

Have you seen


i want to know what the code would look like with all of the factors I stated incorporated into the code.

You could make that a two column table with the second column containing the standard time code.

Then use the lookup-in-pairs block to convert values from column 1 to the result in column 2.

Set conversionTable to create-empty-list
add item ("0000","12:00 midnight") to  conversionTable
for each hour in list ('01', 02', '03',...'11') 
  add item (JOIN(hour,'00'),JOIN(hour,":00 am") ) to  conversionTable
end for each
(see the Method 2 table in my prior link for how to continue this.)
1 Like

but how would I incorporate selection and repetition with that?

See chapters 18,19,20 in the free book at

They show you the blocks that incorporate those techniques.

  set hour to segment(time, 1, lenth (time)-2)
  if hour =24 or hour =0 then 
    return  '12 midnight'
  else if hour>12 then
     return hour-12 && 'pm'
  else if hour=12 then
     return '12pm'
  return hour && 'am'

1 Like