dheerendra
dheerendra

Reputation: 41

How to restrict epoch time in Thingworx

I am creating a thing programmatically and setting its property filed. But if you don't provide time while setting properties its take epoch time in Thingworx.

How to restrict epoch time?

Upvotes: 0

Views: 201

Answers (2)

Durgesh Patel
Durgesh Patel

Reputation: 11

Yes, as a best practice using date-time property value is to set default date as Jan 1 1970 or any backdate value which can be treated similar to something as Null or Default.

Upvotes: -1

JsG
JsG

Reputation: 96

To explain this further, if you don't set a DateTime property on a Thing, essentially making it null/undefined, the property will always report NOW. If you keep refreshing that Thing's property values, it will keep changing to NOW.

This is something I consider to be a Thingworx bug in the DateTimePrimitive. I work around this by, when making DateTime properties, always set a default date, to Jan 1 1970, or Jan 1 2000 or something like that. Then your javascipt service code can know that it is effectively null, and do whatever it needs to do. (You could return the property as a String, and if it's detected as this null date, leave it blank or "Not Set" or whatever you application might need.

Upvotes: 0

Related Questions