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

ThingWorx Navigate is now Windchill Navigate Learn More

Translate the entire conversation x

Current time in a service

byutz
12-Amethyst

Current time in a service

Hello all,

I have what seems like it should be a simple question, but I cant seem to find the answer to it.  I have an event that triggers a subscription.  I have with it the start time of a cycle of a machine, and I would like to get the cycle duration.  I am not being sent up the cycle stop time, so I am going to have to use the current time-cycle start.  How can I get the current time in my service?  I have tried

var currentdate = new Date();

var result=currentdate.getDate()

and it gives me a time in 1969 haha.  Is there an easy way to get the current time stamp?  It should be easy because anytime a property is logged it is used, but I am stumped!

Thank you!

ACCEPTED SOLUTION

Accepted Solutions
byutz
12-Amethyst
(To:byutz)

Just found the answer!

var currentdate = Date.now();

var result=currentdate

View solution in original post

3 REPLIES 3
byutz
12-Amethyst
(To:byutz)

Just found the answer!

var currentdate = Date.now();

var result=currentdate

pschmaltz
12-Amethyst
(To:byutz)

Just doing this also works:

var now= new Date();

result=now;

qn
12-Amethyst
12-Amethyst
(To:byutz)

Thingworx 5.0+ get current date and time using Javascript source code

https://support.ptc.com/appserver/cs/view/solution.jsp?n=CS218294

Announcements


Top Tags