import datetime as dt
# Put the time into a variable.
obj = indigo.server.getTime()
indigo.variable.updateValue('Foobar', str(obj))
# Get the time back out.
obj2 = indigo.variables['Foobar'].value
date_obj = dt.datetime.strptime(obj2, '%Y-%m-%d %H:%M:%S.%f')
# Ways to output the date
indigo.server.log(str(date_obj))
indigo.server.log(str(dt.datetime.strftime(date_obj, '%Y-%m-%d %H:%M:%S')))
indigo.server.log(str(dt.datetime.strftime(date_obj, '%Y-%m-%d %H:%M')))
indigo.server.log(str(dt.datetime.strftime(date_obj, '%m-%d-%Y %H:%M')))
Script 2016-10-01 14:31:52.479000
Script 2016-10-01 14:31:52
Script 2016-10-01 14:31
Script 10-01-2016 14:31
Users browsing this forum: No registered users and 7 guests