cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Did you know you can set a signature that will be added to all your posts? Set it here! X

Timestamp convertion

sponomarenko-3
2-Guest

Timestamp convertion

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.

2 REPLIES 2

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

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);

Top Tags