<?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: Turning an esriFieldTypeDate field (an integer) into a string in ArcGIS JavaScript Maps SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/turning-an-esrifieldtypedate-field-an-integer-into/m-p/322325#M29658</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;Daniel&lt;BR /&gt; Adding plus one as you did solves the problem, thanks. My question is: Why do we have to do this? Is there a bug in the data conversion or am I doing it wrong?&lt;BR /&gt;&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;javascript holds the months (and i think days too) in arrays, the arrays are 0 based. so month[0] is january and month[11] is december so unless you add the 1 your month would actually be off by 1.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 14 Sep 2011 16:26:47 GMT</pubDate>
    <dc:creator>timgogl</dc:creator>
    <dc:date>2011-09-14T16:26:47Z</dc:date>
    <item>
      <title>Turning an esriFieldTypeDate field (an integer) into a string</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/turning-an-esrifieldtypedate-field-an-integer-into/m-p/322319#M29652</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;For my web application, I have a FeatureSet that returns the attribute table of a feature layer, and in that table, there is a date field (esriFieldTypeDate) that I must print. However, when I try that, I get an 11- to 12-digit integer instead of the typical MM/DD/YYYY date string.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The strange thing is, when I use the Query Related Records tool from the ArcGIS Services page, it actually parses the date field correctly... but the source of that page doesn't give any clues as to how it did.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;So, for instance, I get the following:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;51494400000 instead of 1971/08/20 00:00:00 UTC&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;50889600000 instead of 1971/08/13 00:00:00 UTC&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;779328000000 instead of 1994/09/12 00:00:00 UTC&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Is there a pattern I'm not seeing? Is there a special way to parse these integer dates?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 27 Jan 2011 19:47:12 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/turning-an-esrifieldtypedate-field-an-integer-into/m-p/322319#M29652</guid>
      <dc:creator>DanielYim</dc:creator>
      <dc:date>2011-01-27T19:47:12Z</dc:date>
    </item>
    <item>
      <title>Re: Turning an esriFieldTypeDate field (an integer) into a string</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/turning-an-esrifieldtypedate-field-an-integer-into/m-p/322320#M29653</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;For my web application, I have a FeatureSet that returns the attribute table of a feature layer, and in that table, there is a date field (esriFieldTypeDate) that I must print. However, when I try that, I get an 11- to 12-digit integer instead of the typical MM/DD/YYYY date string.&lt;BR /&gt;&lt;BR /&gt;The strange thing is, when I use the Query Related Records tool from the ArcGIS Services page, it actually parses the date field correctly... but the source of that page doesn't give any clues as to how it did.&lt;BR /&gt;&lt;BR /&gt;So, for instance, I get the following:&lt;BR /&gt;&lt;BR /&gt;51494400000 instead of 1971/08/20 00:00:00 UTC&lt;BR /&gt;50889600000 instead of 1971/08/13 00:00:00 UTC&lt;BR /&gt;779328000000 instead of 1994/09/12 00:00:00 UTC&lt;BR /&gt;&lt;BR /&gt;Is there a pattern I'm not seeing? Is there a special way to parse these integer dates?&lt;BR /&gt;&lt;BR /&gt;Thanks&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;using javascript date object to convert milliseconds to string date format like this&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;var date_string= new Date(milliseconds).toUTCString();&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 28 Jan 2011 14:40:06 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/turning-an-esrifieldtypedate-field-an-integer-into/m-p/322320#M29653</guid>
      <dc:creator>HemingZhu</dc:creator>
      <dc:date>2011-01-28T14:40:06Z</dc:date>
    </item>
    <item>
      <title>Re: Turning an esriFieldTypeDate field (an integer) into a string</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/turning-an-esrifieldtypedate-field-an-integer-into/m-p/322321#M29654</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Thank you for the suggestion, hzhu.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;My solution ended up being like this:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;var epoch = new Date(attr.Date);&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;inputStr += (epoch.getMonth() + 1) + "/" + (epoch.getDate() + 1) + "/" + epoch.getFullYear();&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;It ended up being Unix Epoch time (seconds since January 1, 1970).&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 01 Feb 2011 21:23:54 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/turning-an-esrifieldtypedate-field-an-integer-into/m-p/322321#M29654</guid>
      <dc:creator>DanielYim</dc:creator>
      <dc:date>2011-02-01T21:23:54Z</dc:date>
    </item>
    <item>
      <title>Re: Turning an esriFieldTypeDate field (an integer) into a string</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/turning-an-esrifieldtypedate-field-an-integer-into/m-p/322322#M29655</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Daniel&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I have been stuck on this all afternoon. My day and month was always one below what it should have been. Adding plus one as you did solves the problem, thanks. My question is: Why do we have to do this? Is there a bug in the data conversion or am I doing it wrong?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;_covDate = new Date(myAttributes.RecordDate);&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;lt;s:Label text=" {_covDate.getMonth() + '/' + _covDate.getDate() + '/' + _covDate.getFullYear() }"/&amp;gt;&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 13 Sep 2011 23:05:56 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/turning-an-esrifieldtypedate-field-an-integer-into/m-p/322322#M29655</guid>
      <dc:creator>DrewDowling</dc:creator>
      <dc:date>2011-09-13T23:05:56Z</dc:date>
    </item>
    <item>
      <title>Re: Turning an esriFieldTypeDate field (an integer) into a string</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/turning-an-esrifieldtypedate-field-an-integer-into/m-p/322323#M29656</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;Daniel&lt;BR /&gt;&lt;BR /&gt;I have been stuck on this all afternoon. My day and month was always one below what it should have been. Adding plus one as you did solves the problem, thanks. My question is: Why do we have to do this? Is there a bug in the data conversion or am I doing it wrong?&lt;BR /&gt;&lt;BR /&gt;_covDate = new Date(myAttributes.RecordDate);&lt;BR /&gt;&amp;lt;s:Label text=" {_covDate.getMonth() + '/' + _covDate.getDate() + '/' + _covDate.getFullYear() }"/&amp;gt;&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I agree we shouldnt have to do this (we shouldnt have to manually decode domain values either, but we do)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I get the layer description on my queries from the rest service, then check the field type&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;if(ldf.type=="esriFieldTypeDate"){
&amp;nbsp;&amp;nbsp;&amp;nbsp; field_val=&amp;nbsp;&amp;nbsp; dojo.date.locale.format(new Date(field_val), {datePattern: "MM/dd/yyyy"});
&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;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;nbsp; }&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 15:18:20 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/turning-an-esrifieldtypedate-field-an-integer-into/m-p/322323#M29656</guid>
      <dc:creator>JeffPace</dc:creator>
      <dc:date>2021-12-11T15:18:20Z</dc:date>
    </item>
    <item>
      <title>Re: Turning an esriFieldTypeDate field (an integer) into a string</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/turning-an-esrifieldtypedate-field-an-integer-into/m-p/322324#M29657</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I would agree with Jeff, use dojo.date.locale to properly format the date values as strings.&amp;nbsp; Below are some links that might be of some help:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;A href="http://api.dojotoolkit.org/jsdoc/1.6/dojo.date.locale.format" rel="nofollow noopener noreferrer" target="_blank"&gt;http://api.dojotoolkit.org/jsdoc/1.6/dojo.date.locale.format&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;A href="http://www.unicode.org/reports/tr35/tr35-4.html#Date_Format_Patterns" rel="nofollow noopener noreferrer" target="_blank"&gt;http://www.unicode.org/reports/tr35/tr35-4.html#Date_Format_Patterns&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
dojo.require("dojo.date.locale");

_covDate = new Date(myAttributes.RecordDate);

var _covDateStr = dojo.date.locale.format(_covDate, {
&amp;nbsp; selector: 'date',
&amp;nbsp; datePattern: 'MM/dd/yyyy' 
});&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 15:18:23 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/turning-an-esrifieldtypedate-field-an-integer-into/m-p/322324#M29657</guid>
      <dc:creator>JohnGrayson</dc:creator>
      <dc:date>2021-12-11T15:18:23Z</dc:date>
    </item>
    <item>
      <title>Re: Turning an esriFieldTypeDate field (an integer) into a string</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/turning-an-esrifieldtypedate-field-an-integer-into/m-p/322325#M29658</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;Daniel&lt;BR /&gt; Adding plus one as you did solves the problem, thanks. My question is: Why do we have to do this? Is there a bug in the data conversion or am I doing it wrong?&lt;BR /&gt;&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;javascript holds the months (and i think days too) in arrays, the arrays are 0 based. so month[0] is january and month[11] is december so unless you add the 1 your month would actually be off by 1.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 14 Sep 2011 16:26:47 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/turning-an-esrifieldtypedate-field-an-integer-into/m-p/322325#M29658</guid>
      <dc:creator>timgogl</dc:creator>
      <dc:date>2011-09-14T16:26:47Z</dc:date>
    </item>
    <item>
      <title>Re: Turning an esriFieldTypeDate field (an integer) into a string</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/turning-an-esrifieldtypedate-field-an-integer-into/m-p/322326#M29659</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN style="font-family:Arial;"&gt;Ooops didn't realize I was posting in the Javascript form, I'm actually having this problem in flex:o. But good to know it is not api specific. &lt;BR /&gt;&lt;BR /&gt;Just for the record Flex has a data formater object that I think is the same as the dojo.date.locale.format function, but just adding one will probably be less overhead so I continue to use that option.&lt;/SPAN&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;SPAN style="font-family:Arial;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN style="font-family:Arial;"&gt;&lt;BR /&gt;The zero based array method of storing date and month makes perfect sense. Thanks for clearing that up Tim.&lt;BR /&gt;&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 14 Sep 2011 17:50:59 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/turning-an-esrifieldtypedate-field-an-integer-into/m-p/322326#M29659</guid>
      <dc:creator>DrewDowling</dc:creator>
      <dc:date>2011-09-14T17:50:59Z</dc:date>
    </item>
  </channel>
</rss>

