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

Community Tip - New to the community? Learn how to post a question and get help from PTC and industry experts! X

Timestamp convertion

sponomarenko-3
2-Explorer

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

Announcements


Top Tags