<?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 formatting a date/time field in dgrid in ArcGIS JavaScript Maps SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/formatting-a-date-time-field-in-dgrid/m-p/648939#M60491</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I am working with the dgrid and cannot for the life of me figure out how to format the date/time field that I have.&amp;nbsp; Right now it is coming in as a string of numbers.&amp;nbsp; I tried doing this:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;window.grid = new (declare([Grid, Selection])) ({ &amp;nbsp; bufferRows:Infinity, &amp;nbsp; columns: { &amp;nbsp;&amp;nbsp;&amp;nbsp; "id": "ID", &amp;nbsp;&amp;nbsp;&amp;nbsp; "vehicleId": "Vehicle ID", &amp;nbsp;&amp;nbsp;&amp;nbsp; "velocity": {"label": "Speed (MPH)", "formatter":dojoNum.format}, &amp;nbsp;&amp;nbsp;&amp;nbsp; "timestamp": {"label": "Time Stamp", "formatter":dojo.date.locale.format} &amp;nbsp; } }, "grid");&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;But it still didn't work.&amp;nbsp; Is there a way to do this inside the formatter, or do I need to do it some other way?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Michelle&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 13 Feb 2014 19:15:08 GMT</pubDate>
    <dc:creator>MichelleRogers1</dc:creator>
    <dc:date>2014-02-13T19:15:08Z</dc:date>
    <item>
      <title>formatting a date/time field in dgrid</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/formatting-a-date-time-field-in-dgrid/m-p/648939#M60491</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I am working with the dgrid and cannot for the life of me figure out how to format the date/time field that I have.&amp;nbsp; Right now it is coming in as a string of numbers.&amp;nbsp; I tried doing this:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;window.grid = new (declare([Grid, Selection])) ({ &amp;nbsp; bufferRows:Infinity, &amp;nbsp; columns: { &amp;nbsp;&amp;nbsp;&amp;nbsp; "id": "ID", &amp;nbsp;&amp;nbsp;&amp;nbsp; "vehicleId": "Vehicle ID", &amp;nbsp;&amp;nbsp;&amp;nbsp; "velocity": {"label": "Speed (MPH)", "formatter":dojoNum.format}, &amp;nbsp;&amp;nbsp;&amp;nbsp; "timestamp": {"label": "Time Stamp", "formatter":dojo.date.locale.format} &amp;nbsp; } }, "grid");&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;But it still didn't work.&amp;nbsp; Is there a way to do this inside the formatter, or do I need to do it some other way?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Michelle&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 13 Feb 2014 19:15:08 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/formatting-a-date-time-field-in-dgrid/m-p/648939#M60491</guid>
      <dc:creator>MichelleRogers1</dc:creator>
      <dc:date>2014-02-13T19:15:08Z</dc:date>
    </item>
    <item>
      <title>Re: formatting a date/time field in dgrid</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/formatting-a-date-time-field-in-dgrid/m-p/648940#M60492</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi Michelle,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The date value you mentioned is epoch time,which is defined as the number of seconds since midnight (UTC) on 1st January 1970.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;What is epoch time?&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;The Unix epoch (or Unix time or POSIX time or Unix timestamp) is the&amp;nbsp; number of seconds that have elapsed since January 1, 1970 (midnight&amp;nbsp; UTC/GMT), not counting leap seconds (in ISO 8601: 1970-01-01T00:00:00Z).&amp;nbsp; Literally speaking the epoch is Unix time 0 (midnight 1/1/1970), but&amp;nbsp; 'epoch' is often used as a synonym for 'Unix time'. Many Unix systems&amp;nbsp; store epoch dates as a signed 32-bit integer, which might cause problems&amp;nbsp; on January 19, 2038 (known as the Year 2038 problem or Y2038).&amp;nbsp; &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Human readable time&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Seconds&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;1 hour&amp;nbsp;&amp;nbsp;&amp;nbsp; 3600 seconds&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;1 day&amp;nbsp;&amp;nbsp;&amp;nbsp; 86400 seconds&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;1 week&amp;nbsp;&amp;nbsp;&amp;nbsp; 604800 seconds&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;1 month (30.44 days)&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 2629743 seconds&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;1 year (365.24 days)&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 31556926 seconds&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Although when you are retrieving the value and want to display in your application you will have to convert it using the below:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;var someDate = new Date(dateString);&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Hope this helps.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Best Regards,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Manish Patel&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 14 Feb 2014 04:08:50 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/formatting-a-date-time-field-in-dgrid/m-p/648940#M60492</guid>
      <dc:creator>ManishkumarPatel</dc:creator>
      <dc:date>2014-02-14T04:08:50Z</dc:date>
    </item>
    <item>
      <title>Re: formatting a date/time field in dgrid</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/formatting-a-date-time-field-in-dgrid/m-p/648941#M60493</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;Hi Michelle,&lt;BR /&gt;&lt;BR /&gt;The date value you mentioned is epoch time,which is defined as the number of seconds since midnight (UTC) on 1st January 1970.&lt;BR /&gt;&lt;BR /&gt;What is epoch time?&lt;BR /&gt;The Unix epoch (or Unix time or POSIX time or Unix timestamp) is the&amp;nbsp; number of seconds that have elapsed since January 1, 1970 (midnight&amp;nbsp; UTC/GMT), not counting leap seconds (in ISO 8601: 1970-01-01T00:00:00Z).&amp;nbsp; Literally speaking the epoch is Unix time 0 (midnight 1/1/1970), but&amp;nbsp; 'epoch' is often used as a synonym for 'Unix time'. Many Unix systems&amp;nbsp; store epoch dates as a signed 32-bit integer, which might cause problems&amp;nbsp; on January 19, 2038 (known as the Year 2038 problem or Y2038).&amp;nbsp; &lt;BR /&gt;&lt;BR /&gt;Human readable time&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Seconds&lt;BR /&gt;1 hour&amp;nbsp;&amp;nbsp;&amp;nbsp; 3600 seconds&lt;BR /&gt;1 day&amp;nbsp;&amp;nbsp;&amp;nbsp; 86400 seconds&lt;BR /&gt;1 week&amp;nbsp;&amp;nbsp;&amp;nbsp; 604800 seconds&lt;BR /&gt;1 month (30.44 days)&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 2629743 seconds&lt;BR /&gt;1 year (365.24 days)&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 31556926 seconds&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Although when you are retrieving the value and want to display in your application you will have to convert it using the below:&lt;BR /&gt;&lt;BR /&gt;var someDate = new Date(dateString);&lt;BR /&gt;&lt;BR /&gt;Hope this helps.&lt;BR /&gt;&lt;BR /&gt;Best Regards,&lt;BR /&gt;Manish Patel&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I am still confused on where this code would go, and how it would come back into the dgrid.&amp;nbsp; I am fairly new at coding with ESRI, so detailed help would be appreciated.&amp;nbsp; My code is on jsfiddle here: &lt;/SPAN&gt;&lt;A href="http://jsfiddle.net/mrogers83/PDcZ2/1/"&gt;http://jsfiddle.net/mrogers83/PDcZ2/1/&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Michelle&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 14 Feb 2014 12:06:03 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/formatting-a-date-time-field-in-dgrid/m-p/648941#M60493</guid>
      <dc:creator>MichelleRogers1</dc:creator>
      <dc:date>2014-02-14T12:06:03Z</dc:date>
    </item>
    <item>
      <title>Re: formatting a date/time field in dgrid</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/formatting-a-date-time-field-in-dgrid/m-p/648942#M60494</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;When I've used a formatter with my dGrids, I have it call a standalone function instead of doing the formatting work inline. Your modified code would be something like this:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;window.grid = new (declare([Grid, Selection])) ({ &amp;nbsp; bufferRows:Infinity, &amp;nbsp; columns: { &amp;nbsp;&amp;nbsp;&amp;nbsp; "id": "ID", &amp;nbsp;&amp;nbsp;&amp;nbsp; "vehicleId": "Vehicle ID", &amp;nbsp;&amp;nbsp;&amp;nbsp; "velocity": {"label": "Speed (MPH)", "formatter":dojoNum.format}, &amp;nbsp;&amp;nbsp;&amp;nbsp; "timestamp": {"label": "Time Stamp", "formatter":formatTimestamp} &amp;nbsp; } }, "grid"); . . . . function formatTimestamp(value) {&amp;nbsp; var inputDate = new Date(value);&amp;nbsp; return dojo.date.locale.format(inputDate, { &amp;nbsp;&amp;nbsp; selector: 'date', &amp;nbsp;&amp;nbsp; datePattern: 'MM/dd/yyyy'&amp;nbsp;&amp;nbsp; }); }&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 14 Feb 2014 14:16:17 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/formatting-a-date-time-field-in-dgrid/m-p/648942#M60494</guid>
      <dc:creator>SteveCole</dc:creator>
      <dc:date>2014-02-14T14:16:17Z</dc:date>
    </item>
    <item>
      <title>Re: formatting a date/time field in dgrid</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/formatting-a-date-time-field-in-dgrid/m-p/648943#M60495</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;When I've used a formatter with my dGrids, I have it call a standalone function instead of doing the formatting work inline. Your modified code would be something like this:&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;window.grid = new (declare([Grid, Selection])) ({
&amp;nbsp; bufferRows:Infinity,
&amp;nbsp; columns: {
&amp;nbsp;&amp;nbsp;&amp;nbsp; "id": "ID",
&amp;nbsp;&amp;nbsp;&amp;nbsp; "vehicleId": "Vehicle ID",
&amp;nbsp;&amp;nbsp;&amp;nbsp; "velocity": {"label": "Speed (MPH)", "formatter":dojoNum.format},
&amp;nbsp;&amp;nbsp;&amp;nbsp; "timestamp": {"label": "Time Stamp", "formatter":formatTimestamp}
&amp;nbsp; }
}, "grid");
.
.
.
.
function formatTimestamp(value) {
 var inputDate = new Date(value);
 return dojo.date.locale.format(inputDate, {
&amp;nbsp;&amp;nbsp; selector: 'date',
&amp;nbsp;&amp;nbsp; datePattern: 'MM/dd/yyyy' 
 });
}
&lt;/PRE&gt;&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;That did it!&amp;nbsp; The only thing I added was in the datePattern: 'MM/dd/yyyy hh:mm:ss' because I wanted to show the time along with the date.&amp;nbsp; The only problem I came across is that the seconds didn't show up.&amp;nbsp; They just came in as 00 even though I know that the timestamp has seconds because the feature layer is set to refresh every 5 seconds.&amp;nbsp; Any recommendations on how to get it out to the second?&amp;nbsp; My supervisor has said he can live with just minutes if we can't get it down to the second, but would like seconds if possible.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 03:30:30 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/formatting-a-date-time-field-in-dgrid/m-p/648943#M60495</guid>
      <dc:creator>MichelleRogers1</dc:creator>
      <dc:date>2021-12-12T03:30:30Z</dc:date>
    </item>
    <item>
      <title>Re: formatting a date/time field in dgrid</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/formatting-a-date-time-field-in-dgrid/m-p/648944#M60496</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;You could try other tools for formatting your dates. &lt;/SPAN&gt;&lt;A href="http://code.google.com/p/datejs/" rel="nofollow noopener noreferrer" target="_blank"&gt;DateJS&lt;/A&gt;&lt;SPAN&gt; is a good library to have and use. One thing I've learned is that date formatting is NOT consistent across different browsers and DateJS does a pretty good job of doing this.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Another option you can try is simply this:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;function formatTimestamp(value) {
 var inputDate = new Date(value);
 return inputDate.toString();
}&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The text returned will be "Fri Feb 14 09:48:30 PST 2014"&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Steve&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 03:30:33 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/formatting-a-date-time-field-in-dgrid/m-p/648944#M60496</guid>
      <dc:creator>SteveCole</dc:creator>
      <dc:date>2021-12-12T03:30:33Z</dc:date>
    </item>
  </channel>
</rss>

