Good afternoon,
I have a Date field in a hosted Feature layer and I do not know how to print it correctly. It returns an integer, I would like to see the date.
# Access the first layer in the feature layer item (if it has multiple layers)
feature_layer = feature_layer_item.layers[0]
feature_layer
# Query the layer for a specific record
# For example, to find a record with OBJECTID = 1
query = feature_layer.query(where="OBJECTID = 1")
record = query.features[0]
print(record.attributes)
# Date field
lastUpdateAGOL = record.attributes["LAST_UPDAT"]
lastUpdate_dateonly = lastUpdateAGOL.date() ====> Returns an error
Solved! Go to Solution.
Found it:
# Convert the timestamp to a datetime object
date_value = datetime.utcfromtimestamp(lastUpdateAGOL / 1000) # if the timestamp is in milliseconds
# Print the human-readable date
print(date_value.strftime('%Y-%m-%d %H:%M:%S'))
Found it:
# Convert the timestamp to a datetime object
date_value = datetime.utcfromtimestamp(lastUpdateAGOL / 1000) # if the timestamp is in milliseconds
# Print the human-readable date
print(date_value.strftime('%Y-%m-%d %H:%M:%S'))