AnsweredAssumed Answered

Format esriFieldTypeDate from map service

Question asked by jamesfreddyc on Dec 19, 2017
Latest reply on Dec 19, 2017 by jamesfreddyc

I'm querying against an ArcGIS Server feature service and need an assist to convert the date information being returned.  The feature class itself has editor tracking enabled and I'd like to format the last_edit_date value.

 

Description:

  {
   "name": "last_edited_date",
   "alias": "last_edited_date",
   "type": "esriFieldTypeDate",
   "length": 8
  }

 

Value:

"last_edited_date": 1512413066000

 

I'd like to take the value and apply this format: '%Y-%m-%d %H:%M:%S'

 

So far I'm not seeing any success with the various attempts:

#go thru the response
for feature in jsonResultApp['features']:
    lastEditDateStr = feature['attributes']['last_edited_date']
    dFormat = "%Y-%m-%d %H:%M:%S.%f"

    #all of these below fail with various errors
    #attempt 1
    lastEditDate = datetime.datetime.fromtimestamp(lastEditDateStr).strftime('%Y-%m-%d %H:%M:%S')
    #attempt 2
    lastEditDate = datetime.datetime.fromtimestamp(lastEditDateStr).strftime('%c')
    #attempt 3
    lastEditDate = time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(lastEditDateStr))
    #attempt 4
    lastEditDate = datetime.datetime.strftime(d1, dFormat)

Outcomes