Skip to main content
1-Visitor
March 15, 2016
Question

Timestamp convertion

  • March 15, 2016
  • 1 reply
  • 1350 views

Hi, I  need help.

I need to truncate seconds of each time (DATETIME) property of the property.

How can I do that?

I tried this code, but in Value stream I see time value equal to the passed parameter time:

var period 60000;

var t = time; /* input param DATETIME */

t /= period;

t *= period;

var params = {

  propertyName: "SUMconsumption" /* STRING */,

  value: value /* NUMBER */, /* input parameter */

  timestamp: t /* DATETIME */

};

me.AddNumberValueStreamEntry(params);

Thanks in advance.

1 reply

1-Visitor
March 16, 2016

Hi,

Have you tried the following in the script? you can use the format string as required for your application.

     dateFormat(time, "HH:mm")

Regards

Arunkumar D

1-Visitor
March 16, 2016

Hi, Arunkumar.

I don't need a STRING value but I need a DATETIME value to store it into the ValueStream.

I've found such solution:

var period = 300000; //5 min in ms

var periodStart = time.getTime();

periodStart /= period;

periodStart = Math.floor(periodStart) * period;

periodStart = new Date(periodStart);