Get Data Source Time Stamp
-
Please forgive my ignorance, I tried to search the forums but I didn't find any information regarding MetaData points, I think.
I'd like to poll a data source and get the latest time stamp, so I can display it. I don't mind having to poll a particular data point from that source.
I'd like to display year, month, day, hour, minute and second, not particularly in that order.
How can I do this?
-
Hi Mihai,
For an alphanumeric meta point:
var then = new Date(p.time); return then.getFullYear() + "-" + (then.getMonth()+1) + "-" + then.getDate() + " " + then.getHours() + ":" + then.getMinutes() + ":" + then.getSeconds();
This will have your hours in 24-hour time and your months as numerals. If you want to play with Date objects, you can open your developer tools (right click on a webpage, click inspect element or inspect, find the console) and run "dt = new Date()" and see what functions are available.
-
That worked great. Thanks a bunch Phil.
-
Except that I shouldn't have added 1 to then.getDate()! Whoops.
-
Ah you're right I didn't catch that. The day was off +1. Thanks!