[asterisk-users] Decimal seconds?

Mark Murawski markm-lists at intellasoft.net
Mon Mar 28 08:49:46 CDT 2022


Hi Antony,

NOW is not a variable...

In the majority of cases (the exceptions are things like CUT)... 
variables are utilized by ${}

If NOW was a variable you would see it written as ${NOW}

The word NOW is actually not special.  Deep in the Asterisk source (if 
you are curious), the flow is this:


acf_strftime
  -> ast_get_timeval


"NOW" gets passed as a string to ast_get_timeval, which really scans for 
a numeric unixtime.  If the scan fails (if the input is not a proper 
seconds-since-epoch-unixtime), then it uses a default.

Oddly enough you could pass "POTATO" to STRFTIME and it would work just 
fine... since no matter what the value is, if it doesn't parse properly 
the default is ast_tvnow which is a high resolution 'now'





On 3/16/22 09:01, Antony Stone wrote:
> On Wednesday 16 March 2022 at 13:38:44, Tom Ray wrote:
> 
>> What have you actually tried? STRFTIME(NOW,America/Detroit,%3q) doesn't
>> work?
> 
> That works - thank you for the pointer.  I was not aware of the word "NOW" - I
> have always used the variable ${EPOCH} when I needed a timestamp.
> 
> Do you know where this is documented?  I would have expected it to be in
> https://wiki.asterisk.org/wiki/display/AST/Asterisk+Standard+Channel+Variables
> for example, which does mention ${EPOCH}, and also shows an example of
> ${STRFTIME()}, using ${EPOCH} as the timestamp value.
> 
> 
> Antony.
> 




More information about the asterisk-users mailing list