ArcGIS online UTC Time Zone converting to local timezone

14365
34
Jump to solution
11-21-2019 06:44 PM
YashKaja
New Contributor II

We have few DATETIME columns stored in UTC timezone in database. When we view them in ArcGIS online, the timestamps are converted to local timezone, thereby causing the confusion with dates.

"The date and time in a pop-up do not match the date and time in the underlying data."

Followed below articles suggested by support. But no luck. Any thoughts on this issue please? Thanks in advance!

How To: Set the UTC time field to follow a specific time zone 

https://community.esri.com/thread/205882-date-changed-to-strange-values-in-feature-class-when-upload... 

0 Kudos
34 Replies
by Anonymous User
Not applicable

Great to hear you got it working!

0 Kudos
inolaroch
New Contributor III

Hey Peter,

I'm trying to publish individually all the layers in arcgis pro to AGOLE, not as a single Feature Service with all layer at the same time (Every layer has his own feature service).

I'm currently using this code :

import arcpy
import os

# Sign in to portal
arcpy.SignInToPortal('https://Example.maps.arcgis.com', '*******', '*******')

# Set output file names
outdir = r"F:\Projet_ArcGisPro\******\******"
service = "WebMap"
sddraft_filename = service + ".sddraft"
sddraft_output_filename = os.path.join(outdir, sddraft_filename)

# Reference map to publish
aprx = arcpy.mp.ArcGISProject(r"F:\Projet_ArcGisPro\******\*****.aprx")
m = aprx.listMaps(Carte)[0]

lyrs = m.listLayers()

for lyr in lyrs: 
    service = lyr.name 
    sharing_draft = m.getWebLayerSharingDraft("HOSTING_SERVER", "FEATURE", service, lyr)
    sharing_draft.summary = "My Summary"
    sharing_draft.tags = "My Tags"
    sharing_draft.description = "My Description"
    sharing_draft.credits = "My Credits"
    sharing_draft.useLimitations = "My Use Limitations"



# Create Service Definition Draft file
sharing_draft.exportToSDDraft(sddraft_output_filename)


# Stage Service
sd_filename = service + ".sd"
sd_output_filename = os.path.join(outdir, sd_filename)
arcpy.StageService_server(sddraft_output_filename, sd_output_filename)
# Share to portal
print("Uploading Service Definition...")
arcpy.UploadServiceDefinition_server(sd_output_filename, "My Hosted Service")

print("Successfully Uploaded service.")

 

And I'm getting this error :

Capture.JPG

Can you help me please !

Thank you !

0 Kudos
by Anonymous User
Not applicable

Hi @inolaroch - I noticed your other post where it sounds like you successfully published the first layer but the other layers in the map aren't publishing?

I would begin by inserting some print statements after your variables to see what values are going into the subsequent parts of the script. I'll also take a look on my end and see if I can figure out what is going on with it. 

Cheers,

-Peter

MarkJohnson3
New Contributor II

I have this exact same problem. And I guess I'm struggling to understand how I am supposed to use DateAdd or ToUTC functions to convert values back to UTC. My date/time values in my attribute data are already in UTC/Zulu time. I need the Time Aware app in AGOL to read that data correctly. Peter Klingman‌, how would I implement your solution with data in MM/DD/YYYY hh:mm:ss format, in a Date field? Furthermore, my data displays accurately, and plays through as desired in a Web Map in AGOL, but doesn't work at all in a Time Aware app. Many thanks in advance.

0 Kudos
by Anonymous User
Not applicable

Hi Mark Johnson‌,

Thanks for the post - can you share a copy of your layer and the Time Aware app with the ArcGIS Online username PeterK_ess so I can take a closer look? Or if they're public share the links here?

It sounds like something is going on with the configuration of the Time Aware app as the time animation is accurate in the web map. To me this indicates that the date fields do not require any conversion. However looking at the app/layer I think we can figure it out. 

Thanks,

-Peter 

0 Kudos
MarkJohnson3
New Contributor II

Unfortunately, I can't share it. It's all on a closed network with no links to the internet. Sorry.

0 Kudos
by Anonymous User
Not applicable

Hi Mark, no worries. This must mean you are working with Portal? What version/and are you working with Hosted Feature Services (copied to Data Store) or registered Feature Services? 

"...but doesn't work at all in a Time Aware app."

By this, do you mean that the Time Aware app does not pick up the time field, or that the time display is off in the time slider? 

In Portal, Arcade is not available for calculating fields - you will need to use a SQL expression. As long as the date field is a timestamp, the display format shouldn't be consequential. From the documentation page here: Calculate field values—Portal for ArcGIS | Documentation for ArcGIS Enterprise, see the Add time to or subtract time from a date section for how to do this. 

I hope this helps,

-Peter 

0 Kudos
MarkJohnson3
New Contributor II

Yup, working with Portal. Version is ArcGIS Enterprise 10.7.1 Portal. I'm using a Hosted Feature Service for a file geodatabase, which has one feature class, which has the UTC data in question. 

Regarding "doesn't work at all in a Time Aware app", my time field is utilized in a web map, meaning data plays appropriately with a time slider. However, instead of displaying the data as it is stored in the time field, it's converted from UTC to 'local' time in a web map, which for me, is Ohio. I don't want that. I have to display it in UTC time because it's for an app that users all over the world will view. 

Secondly, I can't get the data to display at all in the Time Aware app. I go to configure the app, the time slider is there, displaying the same 'local' time data as it did in the web map, but no features are displayed in the map. When I press play on the time slider, it cycles through the data in the same way it would in a web map, but again, no features are displayed. 

So, I think I have two problems, and I'm not sure if they're related - 1) the undesired time conversion to 'local' time, and 2) features that do display in a web map that won't display in a Time Aware app. 

Ideally, I'd store my time data as UTC, and it would be displayed as UTC. Does that help? 

by Anonymous User
Not applicable

Hi Mark, thank you for the detailed explanation of this; it is really helpful. I'll set up some test data and see if I can address the two issues more comprehensively. 

0 Kudos
by Anonymous User
Not applicable

Hi @MarkJohnson3 - sorry for the delayed response to this post. I tested a lot with the SQL field calculator using the INTERVAL method mentioned to try to change the date to UTC in a field calculation; however, I was only able to get this to work with the current timestamp and not date fields from the feature layer. Arcade is coming to field calculations at ArcGIS Enterprise 10.9; this will make calculating a date field much easier. You will want to use DateAdd(). You can create a new, empty field and calculate date values into it that account for the browser/machine's display in local time, effectively displaying the date in UTC. You could also currently calculate a field in ArcGIS Pro with DateAdd() then republish the feature layer containing the extra field that handles the expected offset to local time in the web map to effectively display UTC.

I hope this helps,

-Peter