How can I get the item updated date in the Arcgis for python api?

155
1
09-29-2020 09:29 AM
New Contributor

I am able to get the item created date using item.created, but item.updated does not seem to be supported.  I think it would be easier to read the documentation for this api if the functions and properties were grouped separately.  (its hard to locate, for example, a list of all of the properties of the item that are exposed through the api.)

Reply
0 Kudos
1 Reply
Esri Contributor

Hi Melanie Bruce‌,

Try using the modified property of the item - this should return a timestamp in the format of milliseconds since epoch which can then be converted into local time.

from arcgis.gis import GIS
import time

item_id = "c08a4282b79d419385f4f242be1d42c0"

gis = GIS("https://machine.example.com/portal", "username", "password")

item = gis.content.search(item_id)[0]
last_udpated = time.localtime(item.modified/1000)

print("Item with id '{}' last updated {}".format(item_id, time.asctime(last_udpated)))

I agree it can at times be a challenge to find the information you're looking for in the API documentation. A trick that I like to use when I'm investigating what properties and methods are available on any kind of python object, is make use of python's built in dir() function. In the example above, if we wanted to know what properties and methods exist for the item variable, we could find this out by printing the output of dir(item).

Hope this helps!

Reply
0 Kudos