Summary
In ArcGIS Online, the EditDate value stored in the hosted feature layer JSON file is written in Epoch time. Epoch time is a non-readable numeric count of seconds or milliseconds. Therefore, the value must be converted into UTC time using the ArcGIS API for Python for easier interpretation.
Procedure
Retrieve the Epoch time from the hosted feature layer JSON file
- Log in to ArcGIS Online with an organization account.
- Click Content > My content and select the hosted feature layer. In this example, it is EditDelete_Demo_Layer.
- Click Settings and select Feature layer (hosted).
- Under Editing options, enable the following settings.
- Toggle Enable editing on.
- Toggle Keep track of changes to the data (add, update, delete features) on.
- Toggle Keep track of who edited the data (editor, name, date and time) on.
- Click Save.
- Click the Overview tab. On the item details page, scroll down to the URL section and click View
.
- Retrieve the Epoch time (the EditDate value) from the hosted feature layer JSON file. Refer to Steps 2b through 5c in FAQ: Can an overwritten feature layer be recovered in ArcGIS Online? for instructions.
- In the same JSON file, find the EditDate syntax above or below deletes.
- Highlight the EditDate value and press Ctrl + C to copy it.
- Paste the syntax in a text editor.
Convert the Epoch time to a local time zone
- In ArcGIS Online, click Notebooks > My notebooks > New notebook > Standard.
- In the notebook, select Code from the drop-down list as the cell type.
-
In the first cell, paste the following code to import the libraries from ArcGIS API for Python and authenticate the connection to ArcGIS Online.
from arcgis.gis import GIS
gis = GIS("home")
Note:
After pasting the code, click Run this cell and advance
to execute the cell before proceeding to the next step.
- In the second cell, paste the following code to import the datetime class.
from datetime import datetime, timezone
- In the third cell, paste the following code to store the Epoch time retrieved from the hosted feature layer JSON file and display it. Replace <EditDate_syntax> with the copied Epoch time. In this example, it is 1773026795628.
deleted = <EditDate_syntax>
print(deleted)
- In the fourth cell, paste the following code to convert the Epoch time to UTC and display the result.
deleted_date = datetime.fromtimestamp(deleted / 1000, tz=timezone.utc).strftime("%c")
print(deleted_date)
- Convert the UTC time to a local time zone.
from zoneinfo import ZoneInfo # Python 3.9+
# Rebuild a timezone-aware UTC datetime from the epoch time
dt_utc = datetime.fromtimestamp(deleted / 1000, tz=timezone.utc)
# Convert UTC to your own local timezone (change the user_timezone according to your own timezone)
user_timezone = "Asia/Kuala_Lumpur"
dt_local = dt_utc.astimezone(ZoneInfo(user_timezone))
print("Local Time Zone:", dt_local)