I have developed a Python script using ArcPy with one of the output variable being of Date type. In the actual Python code, the variable is a Python datetime object which has both the date and time sections.
A snippet of Python script "ExtractNetCDFToRaster.py" is as below.
import sys, osfrom os.path import basenameimport arcpyimport datetimefrom dateutil import tz # Convert UTC datetime to local datetimedef convertToLocalDT(string): from_zone = tz.tzutc() to_zone = tz.tzlocal() # 20/11/2017 1:00:00 PM dtUTC = datetime.datetime.strptime(string, "%d/%m/%Y %I:%M:%S %p") dtLocal = dtUTC.replace(tzinfo=from_zone).astimezone(to_zone) return dtLocal ...# get dimension values from the time dimensiondimension_values = nc_FP.getDimensionValue("time", 0)# the dimension_values is of a unicode type of data, e.g. u'20/11/2017 1:00:00 PM'strDimensionValues = dimension_values.encode('utf-8')arcpy.AddMessage("dimension_values: " + strDimensionValues)dtDimensionValues = convertToLocalDT(strDimensionValues)...# Set dtDimensionValues as output which has an alias of "outDateTime" in the tool Properties window.arcpy.SetParameter(5, dtDimensionValues)
When I imported this script into a Model as a custom tool and ran the tool, the variable only output the date but not the time section. For example, if the actual datetime is "2017-11-21 00:00:00" the outDateTime only shows "21/11/2017" as below.