Hi, I have been looking through several platforms and posts to determine how to add 2 two numbers in a Extension.conf file. i.e. I want to calculate the total minutes that has gone by based on the time of day and will use to generate random numbers. I have many different methods which I have Cleary not got right. Please help - Thank you
same => n,Set(MSTHrs=${STRFTIME(${EPOCH},%H)})
same => n,Set(MSTMins=${STRFTIME(${EPOCH},%M)})
same => n,Set(MSTTotal=(${MSTHrs}*60)+${MSTMins}))
On Tuesday 13 August 2024 at 14:34:54, AskLearner via Asterisk Community
wrote:
Hi, I have been looking through several platforms and posts to determine
how to add 2 two numbers in a Extension.conf file. i.e. I want to
calculate the total minutes that has gone by based on the time of day and
will use to generate random numbers. I have many different methods which
I have Cleary not got right. Please help - Thank you
same => n,Set(MSTHrs=${STRFTIME(${EPOCH},%H)})
same => n,Set(MSTMins=${STRFTIME(${EPOCH},%M)})
same => n,Set(MSTTotal=(${MSTHrs}*60)+${MSTMins}))
As a general rule when asking “what’s wrong with this?” it’s a very good
idea to say what it does do (instead of what you wanted it to do) rather
than simply saying “it doesn’t work” or “it’s not right”.
Asterisk requires arithmetic statements to be placed in square brackets,
therefore your addition statement should be:
same => n,Set(MSTTotal=$[${MSTHrs}*60+${MSTMins}]
Antony.
–
We all get the same amount of time - twenty-four hours per day.
How you use it is up to you.