<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Format time to 12 hour in ArcGIS Online Questions</title>
    <link>https://community.esri.com/t5/arcgis-online-questions/format-time-to-12-hour/m-p/1478341#M59345</link>
    <description>&lt;P&gt;Fingers crossed this will work - just getting the weird issue with arcade having invalid variables.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="leahmaps_0-1716554725069.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/105313iF3F276B9115413FD/image-size/medium?v=v2&amp;amp;px=400" role="button" title="leahmaps_0-1716554725069.png" alt="leahmaps_0-1716554725069.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 24 May 2024 12:45:31 GMT</pubDate>
    <dc:creator>leahmaps</dc:creator>
    <dc:date>2024-05-24T12:45:31Z</dc:date>
    <item>
      <title>Format time to 12 hour</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/format-time-to-12-hour/m-p/1477882#M59330</link>
      <description>&lt;P&gt;Hi everyone,&lt;/P&gt;&lt;P&gt;I have a survey123 feeding a feature layer that I am using in a web map. Two of the questions are time questions, but they submit to the survey as 24 hour time. I am trying to use arcade to change the format to a 12 hour format, but the expression I think should be working isn't.&amp;nbsp;&lt;/P&gt;&lt;P&gt;when I use&amp;nbsp;&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;STRONG&gt;Time($feature.StartTime, 'h:mm A')&lt;/STRONG&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;I get the return of null. If I don't have the formatting, I get the 24 hour time returned. Am I doing something wrong, or is there an issue with this function?&lt;div class="lia-vid-container video-embed-center"&gt;&lt;div id="lia-vid-6353536720112w568h540r709" class="lia-video-brightcove-player-container"&gt;&lt;video-js data-video-id="6353536720112" data-account="6161463677001" data-player="default" data-embed="default" class="vjs-fluid" controls="" data-application-id="" style="width: 100%; height: 100%;"&gt;&lt;/video-js&gt;&lt;/div&gt;&lt;script src="https://players.brightcove.net/6161463677001/default_default/index.min.js"&gt;&lt;/script&gt;&lt;script&gt;(function() {  var wrapper = document.getElementById('lia-vid-6353536720112w568h540r709');  var videoEl = wrapper ? wrapper.querySelector('video-js') : null;  if (videoEl) {     if (window.videojs) {       window.videojs(videoEl).ready(function() {         this.on('loadedmetadata', function() {           this.el().querySelectorAll('.vjs-load-progress div[data-start]').forEach(function(bar) {             bar.setAttribute('role', 'presentation');             bar.setAttribute('aria-hidden', 'true');           });         });       });     }  }})();&lt;/script&gt;&lt;a class="video-embed-link" href="https://community.esri.com/t5/video/gallerypage/video-id/6353536720112"&gt;(view in My Videos)&lt;/a&gt;&lt;/div&gt;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Thu, 23 May 2024 18:31:12 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/format-time-to-12-hour/m-p/1477882#M59330</guid>
      <dc:creator>leahmaps</dc:creator>
      <dc:date>2024-05-23T18:31:12Z</dc:date>
    </item>
    <item>
      <title>Re: Format time to 12 hour</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/format-time-to-12-hour/m-p/1477986#M59338</link>
      <description>&lt;P&gt;The &lt;STRONG&gt;Time&lt;/STRONG&gt; function is meant to pull the time out of an actual DateTime or Time datatype. If I'm not mistaken, Survey123's Time question type stores a &lt;STRONG&gt;string&lt;/STRONG&gt;, so there's nothing for the function to actually work with. You can use Arcade to read the string and modify it to show 12-hour time, though.&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;// split time by colon
var t = Split($feature['StartTime'], ':')

// get the hour as a number
var the_hour = Number(t[0])

// if the hour is 12 - 23, it's PM, otherwise AM
var am_pm = Iif(
  the_hour &amp;gt;= 12,
  'PM',
  'AM
)

// if the hour is 0, re-write as 12
var hour_str = Iif(
  the_hour == 0,
  '12',
  Text(the_hour, '#')
)

// return the various pieces of the time in one string
return `${hour_str}:${t[1]} ${am_pm}`&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 23 May 2024 20:16:41 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/format-time-to-12-hour/m-p/1477986#M59338</guid>
      <dc:creator>jcarlson</dc:creator>
      <dc:date>2024-05-23T20:16:41Z</dc:date>
    </item>
    <item>
      <title>Re: Format time to 12 hour</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/format-time-to-12-hour/m-p/1478341#M59345</link>
      <description>&lt;P&gt;Fingers crossed this will work - just getting the weird issue with arcade having invalid variables.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="leahmaps_0-1716554725069.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/105313iF3F276B9115413FD/image-size/medium?v=v2&amp;amp;px=400" role="button" title="leahmaps_0-1716554725069.png" alt="leahmaps_0-1716554725069.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 24 May 2024 12:45:31 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/format-time-to-12-hour/m-p/1478341#M59345</guid>
      <dc:creator>leahmaps</dc:creator>
      <dc:date>2024-05-24T12:45:31Z</dc:date>
    </item>
    <item>
      <title>Re: Format time to 12 hour</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/format-time-to-12-hour/m-p/1478342#M59346</link>
      <description>&lt;P&gt;That's really odd. I use Arcade this way all the time without issues. Does it let to attempt to run the code, or does it insist there's a problem?&lt;/P&gt;&lt;P&gt;Try adding &lt;STRONG&gt;Console(the_hour) &lt;/STRONG&gt;above line 8, see if it sends anything to the console.&lt;/P&gt;</description>
      <pubDate>Fri, 24 May 2024 12:51:25 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/format-time-to-12-hour/m-p/1478342#M59346</guid>
      <dc:creator>jcarlson</dc:creator>
      <dc:date>2024-05-24T12:51:25Z</dc:date>
    </item>
    <item>
      <title>Re: Format time to 12 hour</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/format-time-to-12-hour/m-p/1478344#M59348</link>
      <description>&lt;P&gt;Oh &lt;EM&gt;sheesh&lt;/EM&gt;. I forgot the closing quotation on line 11. Should be &lt;STRONG&gt;'AM'&lt;/STRONG&gt;.&lt;/P&gt;</description>
      <pubDate>Fri, 24 May 2024 12:55:03 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/format-time-to-12-hour/m-p/1478344#M59348</guid>
      <dc:creator>jcarlson</dc:creator>
      <dc:date>2024-05-24T12:55:03Z</dc:date>
    </item>
  </channel>
</rss>

