AnsweredAssumed Answered

Setting the Time Zone when publishing Map Service via ArcPy?

Question asked by kreuzrsk on Aug 2, 2019
Latest reply on Feb 13, 2020 by crafty762

We are using a bare bones ArcPy Script from the ESRI site to publish Map Services from ArcGIS Pro projects.  When publishing, the default Time Zone is none but we want it changed to Pacific Time with values adjusted for daylight savings.  Is there a way to do this when using arcpy when publishing?


for m in aprx.listMaps():
    if mapNames == "ALL" or mapNames ==
        AddMsgAndPrint("Map: " +
        serviceName =   
        SDPath = os.path.join(tempPath, serviceName + ".sd")
        # Create MapServiceDraft and set service properties
        sddraft = arcpy.sharing.CreateSharingDraft('STANDALONE_SERVER', 'MAP_SERVICE', serviceName, m)
        sddraft.targetServer = server_con
        sddraft.serverFolder = serverFolder
        # copyDataToServer = False will reference data from registered data sources with the targetServer
        sddraft.copyDataToServer = False
        # Read the contents of the original SDDraft into an xml parser
        doc = DOM.parse(SDdraftPath)
        # The follow code piece modifies the SDDraft from a new MapService with caching capabilities
        # to a FeatureService with Map, Create and Query capabilities.
        typeNames = doc.getElementsByTagName('TypeName')
        for typeName in typeNames:
            if == "FeatureServer":
                extention = typeName.parentNode
                for extElement in extention.childNodes:
                    if extElement.tagName == 'Enabled':
               = 'false'
        # Turn off caching
        configProps = doc.getElementsByTagName('ConfigurationProperties')[0]
        propArray = configProps.firstChild
        propSets = propArray.childNodes
        for propSet in propSets:
            keyValues = propSet.childNodes
            for keyValue in keyValues:
                if keyValue.tagName == 'Key':
                    if == "isCached":
               = "false"
        # Write the new draft to disk
        f = open(newSDdraftPath, 'w')
        # Stage the service
        arcpy.StageService_server(newSDdraftPath, SDPath)
        AddMsgAndPrint("  Staged service")
        # Upload the service
        arcpy.UploadServiceDefinition_server(SDPath, server_con)
        AddMsgAndPrint("  Uploaded service")
        # Delete drafts
        AddMsgAndPrint("  Removed temp files")