<?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: Need to return the date and time attributes without UTC conversion in dojox/grid/DataGrid in ArcGIS JavaScript Maps SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/need-to-return-the-date-and-time-attributes/m-p/608765#M56955</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;OK, if nobody knows how to do this&amp;nbsp; then is there another way to format attribute date and time fields when using dojox/grid/DataGrid?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks in advance/&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 09 Dec 2014 23:15:51 GMT</pubDate>
    <dc:creator>GwynnHarlowe</dc:creator>
    <dc:date>2014-12-09T23:15:51Z</dc:date>
    <item>
      <title>Need to return the date and time attributes without UTC conversion in dojox/grid/DataGrid</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/need-to-return-the-date-and-time-attributes/m-p/608764#M56954</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hope someone can help me.&amp;nbsp; My web page is displaying data from a related table using dojox/grid/DataGrid.&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I found a format script that formats it as an actual date and time:&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;//format the date and time that is used in the related table &lt;/P&gt;&lt;P&gt;function formatDate(value) { &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; var inputDate = new Date(value); &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return dojo.date.locale.format(inputDate, {&amp;nbsp; &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; selector: 'date',&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; datePattern: 'MM/dd/yyyy'&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; });&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;function formatTime(value) { &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; var inputDate = new Date(value); &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return dojo.date.locale.format(inputDate, {&amp;nbsp; &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; selector: 'time', &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; timePattern: 'hh:mm a'&amp;nbsp; &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; });&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In my table I call it like this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;th width="100" field="StatusDate" formatter="formatDate"&amp;gt;&amp;lt;em&amp;gt;Date&amp;lt;/em&amp;gt;&amp;lt;/th&amp;gt; &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;th width="100" field="StatusTime" formatter="formatTime"&amp;gt;&amp;lt;em&amp;gt;Time&amp;lt;/em&amp;gt;&amp;lt;/th&amp;gt; &lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This works to get a readable date and time but it assumes it is UTC and the browser converts it to Mountain Standard Time (I am in Arizona).&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is there a way to prevent this so that it displays the date and time as they are in the attribute fields?&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Gwynn&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 05 Dec 2014 15:24:31 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/need-to-return-the-date-and-time-attributes/m-p/608764#M56954</guid>
      <dc:creator>GwynnHarlowe</dc:creator>
      <dc:date>2014-12-05T15:24:31Z</dc:date>
    </item>
    <item>
      <title>Re: Need to return the date and time attributes without UTC conversion in dojox/grid/DataGrid</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/need-to-return-the-date-and-time-attributes/m-p/608765#M56955</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;OK, if nobody knows how to do this&amp;nbsp; then is there another way to format attribute date and time fields when using dojox/grid/DataGrid?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks in advance/&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 09 Dec 2014 23:15:51 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/need-to-return-the-date-and-time-attributes/m-p/608765#M56955</guid>
      <dc:creator>GwynnHarlowe</dc:creator>
      <dc:date>2014-12-09T23:15:51Z</dc:date>
    </item>
    <item>
      <title>Re: Need to return the date and time attributes without UTC conversion in dojox/grid/DataGrid</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/need-to-return-the-date-and-time-attributes/m-p/608766#M56956</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I have been using &lt;A href="http://momentjs.com/"&gt;moment.js&lt;/A&gt; for date/time formatting in web applications and it is great. You should be able to wrap moment.js formatting functions inside the &lt;SPAN style="font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif;"&gt;formatDate() and &lt;SPAN style="font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif;"&gt;formatTime() functions.&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 10 Dec 2014 00:37:10 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/need-to-return-the-date-and-time-attributes/m-p/608766#M56956</guid>
      <dc:creator>OwenEarley</dc:creator>
      <dc:date>2014-12-10T00:37:10Z</dc:date>
    </item>
    <item>
      <title>Re: Need to return the date and time attributes without UTC conversion in dojox/grid/DataGrid</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/need-to-return-the-date-and-time-attributes/m-p/608767#M56957</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;As to why this is happening - &lt;A href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date#Setter"&gt;see here&lt;/A&gt;:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;&lt;P&gt;&lt;SPAN style="color: #4d4e53; font-family: 'Open Sans', sans-serif;"&gt;Creates a JavaScript &lt;/SPAN&gt;&lt;STRONG style="color: #4d4e53; font-family: 'Open Sans', sans-serif;"&gt;&lt;CODE style="margin: 0 0 24px; font-style: inherit; font-weight: inherit; font-family: 'Courier New', 'Andale Mono', monospace;"&gt;Date&lt;/CODE&gt;&lt;/STRONG&gt;&lt;SPAN style="color: #4d4e53; font-family: 'Open Sans', sans-serif;"&gt; instance that represents a single moment in time. &lt;/SPAN&gt;&lt;CODE style="margin: 0 0 24px; font-family: 'Courier New', 'Andale Mono', monospace; color: #4d4e53;"&gt;Date&lt;/CODE&gt;&lt;SPAN style="color: #4d4e53; font-family: 'Open Sans', sans-serif;"&gt; objects are based on a time value that is the number of milliseconds since 1 January, 1970 UTC.&lt;/SPAN&gt;&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #4d4e53; font-family: 'Open Sans', sans-serif;"&gt;The date constructor assumes the input to be UTC. &lt;/SPAN&gt;&lt;SPAN style="color: #4d4e53; font-family: 'Open Sans', sans-serif;"&gt;There is nowhere in your code that is telling Dojo that &lt;/SPAN&gt;&lt;SPAN style="color: #4d4e53; font-family: 'Open Sans', sans-serif;"&gt;your incoming dates are in MST. Dojo appears to be applying an offset to get from UTC to MST based on your browser settings.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #4d4e53; font-family: 'Open Sans', sans-serif;"&gt;However, you may be able to simplify your &lt;SPAN style="font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif;"&gt;formatDate and &lt;SPAN style="font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif;"&gt;formatTime &lt;/SPAN&gt;&lt;/SPAN&gt;functions by removing the &lt;SPAN style="font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif;"&gt;dojo.date.locale.format() and replacing it with a simple moment.js date formatting function. This way the code just assumes input/output values are UTC even though they are actually MST and the results should be displayed as they are in the attribute fields.&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 10 Dec 2014 01:20:50 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/need-to-return-the-date-and-time-attributes/m-p/608767#M56957</guid>
      <dc:creator>OwenEarley</dc:creator>
      <dc:date>2014-12-10T01:20:50Z</dc:date>
    </item>
    <item>
      <title>Re: Need to return the date and time attributes without UTC conversion in dojox/grid/DataGrid</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/need-to-return-the-date-and-time-attributes/m-p/608768#M56958</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you very much.&amp;nbsp; moment.js was just the ticket.&amp;nbsp; This is how I used it:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;function formatDate(value) {&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; var inputDate = new Date(value);&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return moment.utc(inputDate).format("M/D/YYYY");&lt;/P&gt;&lt;P&gt;} &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;function formatTime(value) {&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; var inputDate = new Date(value);&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return moment.utc(inputDate).format('hh:mm a');&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This forces it to display the date and time as it is in the attribute field.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 12 Dec 2014 21:17:11 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/need-to-return-the-date-and-time-attributes/m-p/608768#M56958</guid>
      <dc:creator>GwynnHarlowe</dc:creator>
      <dc:date>2014-12-12T21:17:11Z</dc:date>
    </item>
  </channel>
</rss>

