Question
Eduard Lebedyuk · Aug 31, 2022

Is there a simplier way to get posix time with fractional seconds?

Currently what I have is:

set now = $now()
set ts = $zdt(now,-2) _ "." _ $p(now, ".", 2)

Docs state (for -2 dformat):

Fractional seconds in the input value are permitted, but ignored.
 
I wonder if there's some other way to get posix time with fractional seconds?
0
0 96
Discussion (4)2
Log in or sign up to continue

How about this? :-)

USER>w ##class(%SYS.Python).Import("time").time()
1661966455.799232244

Except that calling Python is about 10x slower, although it gives probably the value that you want.
$Now() gives a different value because it doesn't take Daylight Savings Time into account.
 

Except that calling Python is about 10x slower, a

Not really, more like faster if you need to call it more than once:

 
Code

Results in:

 
Output