Search code examples
javascriptjsonnode.jsazureazure-stream-analytics

converting Javascript's Date.now() into timestamp in Stream Analytics


I tried to collect pressure values by using Node.js in my Raspberry Pi and Azure Stream Analytics in my Azure IoT Hub. I sent the data to IoT Hub as JSON file using this code :

var data = JSON.stringify({ 
               deviceId: "myRaspi10",
               pressureVal: value, 
               time:Date.now() 
           });

When I checked the console, here's what being sent to the Hub

{
    "deviceId":"myRaspi10",
    "pressureVal":39,
    "time":1470642749428
}

How to convert the time value into timestamp in the Azure Stream Analytics?


Solution

  • Try sending new Date() instead of Date.now(). It will produce a string output like "2016-08-08T08:22:34‌​.905Z" which may be Azure Stream Analytics would treat like a date. (Haven't used it though, just an idea).