datetime vs etime precision

Posted by bronco on 26-Nov-2014 03:29

For logging purposes: is there any difference in precision between subtracting two datetime-tz's and two etime's (to measure the elapsed time)? I know etime is "risky" because it can be reset during the call, etime(true), but apart from that?

My assumption there is no difference, but just want to verify.

versions: OE11.3 and up.

Posted by Matt Gilarde on 26-Nov-2014 03:53

ETIME and NOW use the same OS functions to get the current time. The only differences I see are that NOW has to handle time zones so it takes a tiny bit more time to execute than ETIME and NOW will use a time server if one is available. Other than that, I believe they are both as accurate to the millisecond as the system timer allows them to be.

All Replies

Posted by Matt Gilarde on 26-Nov-2014 03:53

ETIME and NOW use the same OS functions to get the current time. The only differences I see are that NOW has to handle time zones so it takes a tiny bit more time to execute than ETIME and NOW will use a time server if one is available. Other than that, I believe they are both as accurate to the millisecond as the system timer allows them to be.

Posted by bronco on 26-Nov-2014 07:16

OK, thanks for confirming my assumption. I'll switch to datetime-tz for "calculating" the elapsed time in a call. Saves me from the annoyance when somebody uses etime(true) in between the begin and end of the call.

Posted by James Palmer on 26-Nov-2014 07:18

Check out the mtime function.

This thread is closed