问题
In Dyalog APL I can use the function ⎕TS
to get the current year, month, day, hour, minute, second etc, but is there a way to get the current timestamp in seconds from e.g. 1970-01-01 (Unix timestamp)?
回答1:
Using days
from https://dfns.dyalog.com/n_days.htm
)copy dfns days
C:\Program Files\Dyalog\Dyalog APL-64 17.1 Unicode\ws\dfns.dws saved Wed Aug 21 19:40:24 2019
86400×(days ⎕TS)-(days 1970 1 1)
1570618030
Could also use the over ⍥
operator, coming in Dyalog version 18.0
)copy dfns days
C:\Program Files\Dyalog\Dyalog APL-64 17.1 Unicode\ws\dfns.dws saved Wed Aug 21 19:40:24 2019
O←{(⍺⍺ ⍺)⍵⍵ ⍺⍺ ⍵} ⍝ The over operator
86400×⎕TS days O - 1970 1 1
1570618337
来源:https://stackoverflow.com/questions/58300764/how-do-i-get-current-timestamp-in-seconds