Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unix Timestamp in kdb/q

Is there a built-in way of getting the Unix timestamp in kdb/q?

Something like

`float$.z.p

would be ideal; otherwise I'll have to resort to a more laborious implementation where I count the seconds from Jan 1 1970.

like image 736
nightTrevors Avatar asked Oct 01 '22 08:10

nightTrevors


1 Answers

q)`long$.z.p
458558447196132000
q)`long$1970.01.01D00:00
-946684800000000000

So you can get nanos from 2000.01.01. From there it's a simple calculation to convert to and from a 2000.01.01-based epoch vs 1970.01.01 based epoch.

like image 133
Manish Patel Avatar answered Oct 04 '22 19:10

Manish Patel