The Senseforce timestamp is formatted as UNIX timestamp with millisecond precision. For our Python scripting engine, this looks like an ordinary integer.

To create a date object, use the following snippet:

dtime.datetime.fromtimestamp(timestamp/ 1000).astimezone(tz.gettz('Europe/Vienna'))

One can get the Cities to get the correct time zone from

  • Assuming, "timestamp" is a Senseforce/UNIX timestamp in millisecond, divide it by 1000, to create a second-resolution timestamp
  •  Use fromtimestamp to create the date object. The origin is starts at 1970-01-01 (which is the case for Senseforce/UNIX timestamps), The astimezone method gives the date object a timezone attribute, tz.gettz specifies the time zone by a "continent/city" argument, which can be obtained on Note, that Senseforce-timestamps are always UTC.

To use a Python date object outside a script, define a script result variable with datatype either "timestamp" or "string". Using "string" has the advantage of formatting the date-time object as you like.

Use the following code snippets to correctly format the date-objects to meet the correct output format requirements:

  • String: 
outputString = pythonDateTimeObj.strftime('%Y-%m-%d %H:%M:%S')
outputString = pythonDateTimeObj.isoformat()

Result example: '2019-03-27 12:13:10'

  • Timestamp:
outputTimestamp = pythonDateTimeObj.timestamp() * 1000

Result example: 1552518000000