I'm working on a script to ingest some data, create some data layers with it, and publish that to ArcGIS Server.

Most of that is done with no problem, but I got a new requirement today, time-enabling some of those feature layers. That looks pretty straight-forward, but it isn't working as I'd expect, so I'm hoping someone or some ones here can help.

# dFrame is the data frame, lyrName is the name of the new layer
def createLayer (self, dFrame, lyrName):
    lyrFileName = ...
    timeLyrFileName = ...

    arcpy.MakeFeatureLayer_management (lyrName, lyrName + self.lyrSuffix)
    arcpy.SaveToLayerFile_management (lyrName + self.lyrSuffix, lyrFileName)
    newLyr = arcpy.mapping.Layer (lyrFileName)
    # set some other layer properties that are working fine
    arcpy.mapping.AddLayer (dFrame, newLyr)

    if not os.path.isfile (timeLyrFileName):
      timeLyr = arcpy.mapping.Layer (timeLyrFileName)

    if not timeLyr is None:
      arcpy.mapping.UpdateLayerTime (dFrame, newLyr, timeLyr)

(The mxd holding the data frame is saved after this method returns.) If I put some print statements after that call to UpdateLayerTime, everything looks good. newLyr.time.isTimeEnabled is True, newLyr.time.timeOffset is the same as timeLyr.time.timeOffset (though, oddly, both show as 0.0 years rather than 1.0 hours. Hoping just a small bug in EsriTimeOffset's toString method (or whatever the python equivalent of that is)), and newLyr.time.timeStartField also looks correct.

The fly in the ointment now is that, when the program finishes, if I open the mxd in Desktop, the layers created are all there, but none of them are time-enabled. (FWIW, we're running the ArcPy that came with Server 10.6.)

Anyone got a clue what's going on?

2 Answers 2


You don't say what your layers are, in the Layer help file it states:

Time-management operations can be performed for time-enabled layers. Not all layer types support time properties. Therefore, it is good practice to first test if the layer supports time using the supports method. If the layer does support time, then time properties can be accessed from the LayerTime class.

So maybe you are trying to apply time to a layer that cannot support it.

[Enable Time for a layer using arcpy2 on the Esri Community hints to the fact that your layer must be time enabled and the TimeLayer class is read only. I don't think you can just turn it on using arcpy, so a bit like you can't create layout elements with ArcPy, modify then yes, but not create.

Finally, you don't say or tag what software you are using! Now this too is a shot in the dark but ArcGIS Pro allows you to access many more properties of a layer that arcpy exposes using CIM. I've tinkered around with it but not really used it. If you are using ArcGIS Pro then explore CIM as you may be able to delve right in and change all the time properties.


A shot in the dark answered the question. Call UpdateLayerTime() before calling AddLayer(). Certainly begs the question of why the data frame is an argument to UpdateLayerTime().

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.