<?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: Strange date output from ArcGIS Online feature layer using ArcGIS API for Python in ArcGIS API for Python Questions</title>
    <link>https://community.esri.com/t5/arcgis-api-for-python-questions/strange-date-output-from-arcgis-online-feature/m-p/799311#M1992</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;It appears to be a unix timestamp in nanoseconds.&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;Scientific notation
1.5390954e+18
+18 move decimal 18 places to right

Timestamp in nanoseconds
1539095400000000000

Converts to UTC as:
Tuesday, October 9, 2018 2:30:00 PM
‍‍‍‍‍‍‍‍‍&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;If you convert the UTC for your timezone, it should match.&amp;nbsp; AGOL usually stores the date as timestamp; but I would have expected milliseconds.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;&lt;SPAN class="keyword token"&gt;from&lt;/SPAN&gt; datetime &lt;SPAN class="keyword token"&gt;import&lt;/SPAN&gt; datetime
&lt;SPAN class="keyword token"&gt;from&lt;/SPAN&gt; dateutil &lt;SPAN class="keyword token"&gt;import&lt;/SPAN&gt; tz
&lt;SPAN class="keyword token"&gt;from&lt;/SPAN&gt; pytz &lt;SPAN class="keyword token"&gt;import&lt;/SPAN&gt; timezone

ts &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; float&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;"1.5390954e+18"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;

UTC &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; datetime&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;utcfromtimestamp&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;ts &lt;SPAN class="operator token"&gt;//&lt;/SPAN&gt; &lt;SPAN class="number token"&gt;1000000000&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;replace&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;tzinfo&lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt;tz&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;tzutc&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
&lt;SPAN class="keyword token"&gt;print&lt;/SPAN&gt; UTC
&lt;SPAN class="comment token"&gt;# 2018-10-09 14:30:00+00:00&lt;/SPAN&gt;

east &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; UTC&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;astimezone&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;timezone&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;'Canada/Eastern'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
&lt;SPAN class="keyword token"&gt;print&lt;/SPAN&gt; east
&lt;SPAN class="comment token"&gt;# 2018-10-09 10:30:00-04:00&lt;/SPAN&gt;&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sun, 12 Dec 2021 09:15:08 GMT</pubDate>
    <dc:creator>RandyBurton</dc:creator>
    <dc:date>2021-12-12T09:15:08Z</dc:date>
    <item>
      <title>Strange date output from ArcGIS Online feature layer using ArcGIS API for Python</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/strange-date-output-from-arcgis-online-feature/m-p/799310#M1991</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I'm trying to extract field value from an ArcGIS Online feature layer using the ArcGIS API for Python.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In ArcGIS Online, the date is displayed like&amp;nbsp;&lt;STRONG&gt;10/9/2018&amp;nbsp;10:30 AM&lt;/STRONG&gt;&amp;nbsp;(Field type = DATE)&lt;/P&gt;&lt;P&gt;From the Spatially Enabled Panda DataFrame, the date looks like&amp;nbsp;&lt;STRONG&gt;1.5390954e+18&lt;/STRONG&gt;.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;When I try to copy the date in a File Geodatabase (InsertCursor) from the DataFrame into a DATE field, I'm getting this error:&lt;/P&gt;&lt;P&gt;&lt;EM&gt;&lt;STRONG&gt;RuntimeError: The value type is incompatible with the field type.&lt;/STRONG&gt;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;How can I convert the &lt;STRONG&gt;1.5390954e+18&amp;nbsp;&lt;/STRONG&gt;formatted date to a proper date format to be insert in a DATE field?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 01 May 2020 20:24:22 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/strange-date-output-from-arcgis-online-feature/m-p/799310#M1991</guid>
      <dc:creator>TransCanadaTrailTCT</dc:creator>
      <dc:date>2020-05-01T20:24:22Z</dc:date>
    </item>
    <item>
      <title>Re: Strange date output from ArcGIS Online feature layer using ArcGIS API for Python</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/strange-date-output-from-arcgis-online-feature/m-p/799311#M1992</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;It appears to be a unix timestamp in nanoseconds.&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;Scientific notation
1.5390954e+18
+18 move decimal 18 places to right

Timestamp in nanoseconds
1539095400000000000

Converts to UTC as:
Tuesday, October 9, 2018 2:30:00 PM
‍‍‍‍‍‍‍‍‍&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;If you convert the UTC for your timezone, it should match.&amp;nbsp; AGOL usually stores the date as timestamp; but I would have expected milliseconds.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;&lt;SPAN class="keyword token"&gt;from&lt;/SPAN&gt; datetime &lt;SPAN class="keyword token"&gt;import&lt;/SPAN&gt; datetime
&lt;SPAN class="keyword token"&gt;from&lt;/SPAN&gt; dateutil &lt;SPAN class="keyword token"&gt;import&lt;/SPAN&gt; tz
&lt;SPAN class="keyword token"&gt;from&lt;/SPAN&gt; pytz &lt;SPAN class="keyword token"&gt;import&lt;/SPAN&gt; timezone

ts &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; float&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;"1.5390954e+18"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;

UTC &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; datetime&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;utcfromtimestamp&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;ts &lt;SPAN class="operator token"&gt;//&lt;/SPAN&gt; &lt;SPAN class="number token"&gt;1000000000&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;replace&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;tzinfo&lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt;tz&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;tzutc&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
&lt;SPAN class="keyword token"&gt;print&lt;/SPAN&gt; UTC
&lt;SPAN class="comment token"&gt;# 2018-10-09 14:30:00+00:00&lt;/SPAN&gt;

east &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; UTC&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;astimezone&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;timezone&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;'Canada/Eastern'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
&lt;SPAN class="keyword token"&gt;print&lt;/SPAN&gt; east
&lt;SPAN class="comment token"&gt;# 2018-10-09 10:30:00-04:00&lt;/SPAN&gt;&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 09:15:08 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/strange-date-output-from-arcgis-online-feature/m-p/799311#M1992</guid>
      <dc:creator>RandyBurton</dc:creator>
      <dc:date>2021-12-12T09:15:08Z</dc:date>
    </item>
    <item>
      <title>Re: Strange date output from ArcGIS Online feature layer using ArcGIS API for Python</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/strange-date-output-from-arcgis-online-feature/m-p/799312#M1993</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;A href="https://community.esri.com/migrated-users/163261"&gt;TransCanadaTrail TCT&lt;/A&gt;‌, I just did some querying of feature layers using the ArcGIS API for Python, and I am not seeing the date behavior you are seeing.&amp;nbsp; It may be your issue is with the spatially-enabled data frame.&amp;nbsp; Can you show a code example of how you are creating the data frame?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 02 May 2020 15:10:11 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/strange-date-output-from-arcgis-online-feature/m-p/799312#M1993</guid>
      <dc:creator>JoshuaBixby</dc:creator>
      <dc:date>2020-05-02T15:10:11Z</dc:date>
    </item>
    <item>
      <title>Re: Strange date output from ArcGIS Online feature layer using ArcGIS API for Python</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/strange-date-output-from-arcgis-online-feature/m-p/799313#M1994</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I'm not sure if it's the way that I'm querying the feature layers, because I'm using the same process for other layers and it's working well. The only thing about this layer is the layer have not been created directly from ArcGIS Online, but it's an upload from ArcGIS Pro (SDE Geodatabase). Here is the code&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;&lt;SPAN class="keyword token"&gt;from&lt;/SPAN&gt; arcgis&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;gis &lt;SPAN class="keyword token"&gt;import&lt;/SPAN&gt; GIS
&lt;SPAN class="keyword token"&gt;from&lt;/SPAN&gt; arcgis&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;features &lt;SPAN class="keyword token"&gt;import&lt;/SPAN&gt; GeoAccessor&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; GeoSeriesAccessor
&lt;SPAN class="keyword token"&gt;import&lt;/SPAN&gt; pandas &lt;SPAN class="keyword token"&gt;as&lt;/SPAN&gt; pd


item &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; gis&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;content&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;get&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;"id_item"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
agol_layer &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; item&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;layers&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;0&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;

records &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; pd&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;DataFrame&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;spatial&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;from_layer&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;agol_layer&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 09:15:11 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/strange-date-output-from-arcgis-online-feature/m-p/799313#M1994</guid>
      <dc:creator>TransCanadaTrailTCT</dc:creator>
      <dc:date>2021-12-12T09:15:11Z</dc:date>
    </item>
    <item>
      <title>Re: Strange date output from ArcGIS Online feature layer using ArcGIS API for Python</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/strange-date-output-from-arcgis-online-feature/m-p/799314#M1995</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The code you are using is pretty boilerplate, so nothing seems odd there.&amp;nbsp; Plus, you mention other layers work fine.&amp;nbsp; At this point, it seems to be something in the translation/upload from Pro to AGOL.&amp;nbsp; It might be worth opening a case with Esri Support to dive deeper.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 04 May 2020 14:34:13 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/strange-date-output-from-arcgis-online-feature/m-p/799314#M1995</guid>
      <dc:creator>JoshuaBixby</dc:creator>
      <dc:date>2020-05-04T14:34:13Z</dc:date>
    </item>
    <item>
      <title>Re: Strange date output from ArcGIS Online feature layer using ArcGIS API for Python</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/strange-date-output-from-arcgis-online-feature/m-p/799315#M1996</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks Randy. You nailed it. It's working now. I never thought to get a date in this format.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 04 May 2020 15:07:08 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/strange-date-output-from-arcgis-online-feature/m-p/799315#M1996</guid>
      <dc:creator>TransCanadaTrailTCT</dc:creator>
      <dc:date>2020-05-04T15:07:08Z</dc:date>
    </item>
  </channel>
</rss>

