Get Current time in Milliseconds
I am trying to generate a timestamp of the current time but in milliseconds. Is there a scripting option to do this, perhaps Extension tool, or is it possible to generate it via the Data Generator Tool?
Comments
-
This is possible in the Data Generator Tool, you will want to use a syntax like the following:
HH:mm:ss.SSS or hh:mm:ss.SSS a
This will give you a time stamp like
13:30:00.010 or 01:30:00.010 PM, respectively.Hope this helps!
0 -
Hey Thomas, will this generate the timestamp as just the number of milliseconds?
Ex: 12 pm -> 12333434 milliseconds0 -
We have a script that does this but I haven't adjusted yet to Virtualize, additionally, I want to see if I could use the Data Generator Tool instead:
import java.util.GregorianCalendar;
GregorianCalendar cal = new GregorianCalendar();
responsedate = cal.getTimeInMillis();testExec.setStateObject("responsedate", responsedate);
0 -
I think in that case I missed your question It looks like this should be handled in an extension tool.
If you want to do this in Javascript, then I would use the following:
var d = new Date("<Today's Date>");
var n = d.getMilliseconds();More info on this here:
https://www.w3schools.com/jsref/jsref_getmilliseconds.asp0 -
Hey Thomas, that resource works however it returns a three digit number
I dug around and produced this Groovy script which works:
import com.parasoft.api.*
public int getMili(){
Calendar responsedate = Calendar.getInstance();return responsedate.getTimeInMillis() / 1000;
}
0 -
Folks, just use java.lang.System.currentTimeMillis()
1