1

How can we use this particular code in the execution process:

now = new Date();
current_date = new Date(now.getUTCFullYear(), now.getUTCMonth(), now.getUTCDate(), now.getUTCHours(), now.getUTCMinutes(), now.getUTCSeconds());
end_date = obj.end_date (Mon, 02 Apr 2012 20:16:35 GMT);
var millisDiff = end_date.getTime() -  current_date.getTime();
console.log(millisDiff / 1000);

I have already inserted my records into a collection. It consists of many parameters. The first record tells the status to be started and the last record tells that the process has ended. They also consist of the time stamp values in all the records on when it started and when it ended.

How can I get the difference in time between the two processes? How can I use the above code?

db.trials.insert( { _id: ObjectId("51d2750d16257024e046c0d7"), Application: "xxx", ProcessContext: "SEARCH", InteractionID: "I001", opID: "BBB", buID: "Default", HostName: "xxx-ttt-tgd-002", InstanceName: "Instance1", EventTime: ISODate("2011-11-03T14:23:00Z"), HOPID: "", HOPName: "", HOPStatus: "", INTStatus: "Started" } );
db.trials.insert( { _id: ObjectId("51d2750d16257024e046c0d7"), Application: "xxx", ProcessContext: "SEARCH", InteractionID: "I001", opID: "BBB", buID: "Default", HostName: "xxx-ttt-tgd-002", InstanceName: "Instance1", EventTime: ISODate("2011-11-03T14:23:58Z"), HOPID: "", HOPName: "", HOPStatus: "", INTStatus: "Started" } );

These are the 2 records for which I wanted to know the time stamp difference using the above logic. How can I use the logic such that I can get the difference?

4

0 回答 0