Any Suggestions on How to Get System In JavaScript
I'm working in the FrameMaker ExtendScript editor and want my script to log start and end times to the console in hours:minutes:seconds. I've written the code below, which just keeps writing the same time over and over. The timeNow variable only changes when the script is first started, and sometimes not even then. When I run the script without the loop and without the function, it appears to run fine; giving me a new current time each time I run it. Thoughts, suggestions...easier way to do this?
//Test of a timeNow function for timing script
//start and end
var timeNow, strSeconds;
for (var i = 0; i < 6; i++){ //Function test loop
for (var j = 0; j < 100000000; j++){ //Timer
}
getTimeStamp();
$.writeln(timeNow);
}
function getTimeStamp() {
var timeNow;
var hours = (new Date()).getHours();
var minutes = (new Date()).getMinutes();
var seconds = (new Date()).getSeconds();
if (seconds <= 9) {
strSeconds = "0" + seconds.toString();
timeNow = hours + ":" + minutes + ":" + strSeconds;
} else {
timeNow = hours + ":" + minutes + ":" + seconds;
}
return(timeNow);
}
