I came across an issue working on a script enhancement for a customer where I needed to compare two time/date variables and evaluate the seconds that have expired between them. The CRS development guide says that using the “.ms” method on a time variable would return epoch time but that is not so, or at least not the case with version 4.0.
CRS has Date variables and Time variables. Date variables support multiple formats but will capture time values as well as MM/DD/YY values. Time variables will get HH:MM:SS.ms AM|PM values. According to the CRS developer guide, if you have a date variable and use the “.ms” method you will get the number of milliseconds since January 1, 1970, 00:00:00 GMT (aka Unix epoch or epoch time).
Unfortunately, the developer guide is either incorrect or I am completely misunderstanding the document. Whichever is the case, the syntax (and I tried multiple methods) isn’t getting me what it is supposed to. Instead, I get the actual milliseconds for a specific instance in time.
To work around this issue you have to execute a couple of conversions and assign the value to a variable of type long. This is done as follows:
Set lngEnterQ = Date.parse(D[now].toGMTString())
Basically, this will return the milliseconds that have expired since Jan 1, 1970 00:00:00 GMT. It took some reading of the Java API to put that together. The CRS developer guide does say you can do the .parse() and .toGMTString() functions but doesn’t explain them at all. The .toGMTString() is pretty intuitive but the .parse() was not what I thought it was.
Here’s to Google and Sun’s Java documentation library.