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

To create a date object, use the following snippet:

as.POSIXct(timestamp/1000, origin = "1970-01-01", tz="Europe/Vienna")
  • Assuming, "timestamp" is a Senseforce/UNIX timestamp in millisecond, divide it by 1000, to create a second-resolution timestamp
  • Use as.POSIXct to create the date object. The origin-parameter is required, to indicate that the timestamp starts at 1970-01-01 (which is the case for Senseforce/UNIX timestamps), The tz-parameter optionally provides information about the timezone in which the date-object is displayed. Note, that Senseforce-timestamps are always UTC. 

To use a R 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: 
outputStringTimestamp = as.character(internalDateObject)

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

  • Timestamp:
outputTimestamp = as.numeric(internalDateObject)*1000

Result example: 1552518000000