HOW TO

Convert Epoch time for edited data using API for Python in ArcGIS Notebooks

Last Published: March 24, 2026

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

  1. Log in to ArcGIS Online with an organization account.
  2. Click Content > My content and select the hosted feature layer. In this example, it is EditDelete_Demo_Layer.
    select the hosted feature layer in the Content tab
  3. Click Settings and select Feature layer (hosted).
    Click Settings and select the Feature layer (hosted) section
  4. Under Editing options, enable the following settings.
    1. Toggle Enable editing on.
    2. Toggle Keep track of changes to the data (add, update, delete features) on.
    3. Toggle Keep track of who edited the data (editor, name, date and time) on.
    4. Click Save.
    Editing options under the Feature layer (hosted) section
  5. Click the Overview tab. On the item details page, scroll down to the URL section and click View View icon in the URL section .
    View icon in the URL section
  6. 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.
    1. In the same JSON file, find the EditDate syntax above or below deletes.
    2. Highlight the EditDate value and press Ctrl + C to copy it.
      EditDate syntax in the JSON file
    3. Paste the syntax in a text editor.

Convert the Epoch time to a local time zone

  1. In ArcGIS Online, click Notebooks > My notebooks > New notebook > Standard.
    Select Standard as the Template
  2. In the notebook, select Code from the drop-down list as the cell type.
    Select Code as the cell type
  3. 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 Run this cell and advance icon to execute the cell before proceeding to the next step. 
  4. In the second cell, paste the following code to import the datetime class.
    from datetime import datetime, timezone
    
  5. 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)
    
  6. 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)
    
  7. 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)
    
    Output display of the Python codes in the ArcGIS Notebooks

Article ID: 000038797

Software:
  • Online
  • ArcGIS API for Python

Get support with AI

Resolve your issue quickly with the Esri Support AI Chatbot.

Start chatting now

Related Information

Discover more on this topic

Get help from ArcGIS experts

Contact technical support

Start chatting now

Go to download options