How to get from caché server actual linux TIMESTAMP(in seconds)?

Good day,

I need to find out if it is possible somehow to receive actual linux TIMESTAMP for example with $NOW() or other functions.
I was trying to recalculate it with $NOW() function, but without success. I would like to simulate Redis TIME command in COS.

My tryings:

USER > set time = $NOW()

USER > w (($PIECE(time,",",1)*86399) + $PIECE(time,",",2))

But in Redis it is:

> time
​1) 1502471158

On web page:
type "time" + enter. And it will results as short documentation says:

And this behavior I would like to implement in COS.

Additional sub-question for this question is:
How to receive number of elapsed microseconds from caché server actual linux TIMESTAMP from actual second? Is it possible?

Thanks in advance for your thoughts/answers.

  • 0
  • 0
  • 211
  • 4
  • 3


I wrote this function to get the Linux UTC time, which I'm pretty sure is what Redis time is showing. 


​USER>W (+$ZTS-47117*86400) + $J($P($ZTS,",",2),0,0)


> time

1) 1502473916



When processing the two pieces of a timestamp such as $ZTS it is safer to assign the timestamp once to a variable, then operate on that variable, e.g.  instead of

W (+$ZTS-47117*86400) + $J($P($ZTS,",",2),0,0)


S zts=$ZTS W (+zts-47117*86400) + $J($P(zts,",",2),0,0)

This avoids the edge case in the original code, where the first evaluation of $ZTS happens just before the midnight rollover and the second evaluation at or just after it.

As to your second part, $ZTS is the most precise time you have.
On unix:

The $ZTIMESTAMP time value is a decimal numeric value that counts the time in seconds and fractions thereof. The number of digits in the fractional seconds may vary from zero to nine, depending on the precision of your computer’s time-of-day clock. On Windows systems the fractional precision is three decimal digits; on UNIX® systems it is six decimal digits. $ZTIMESTAMP suppresses trailing zeroes or a trailing decimal point in this fractional portion.