How do I get current timestamp in seconds?

流过昼夜 提交于 2021-01-28 05:46:17

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!