How to change default timezone in CDR functionsu

Hello everyone,
I am trying to get the correct time for ${CDR(start)}.
The timezone is configured correctly, the server’s date / time is correct but ${CDR(start)} return a bad time (for 20:10 it returns 19:10).
I found the setting for CDR CSV (usegmttime=no) and it works but only for the cdr_csv.
Is it a way to alter the CDR in the dialplan ?
thanks

I’m assuming you are in Central European Time, in the Winter, and that you are looking at the values using the CDR function.

I would suggest that usegmt=no is a bad idea. It will cause you problems if you have users in more than one timezone, and for calls that are in progress during daylight saving time transitions.

If the setting is for CSV, it means that the internal CDRs are in UTC.

If you want CET values, I’d suggest using the u option, to get the raw Posix time and then using STRFTIME() to convert to your local timezone.

Thanks for your answer.
What do you mean by using the u option ?
There is my log command :

exten => h,1,Set(${variablepos}=${SHELL(echo "cdr_numposte : ${CHANNEL(endpoint)}\ncdr_date : ${CDR(start)}\ncdr_caller : ${CALLERID(num)}\ncdr_called : ${CDR(dst)}\ncdr_forfait : ${CONTEXT}\ncdr_statut : ${CDR(disposition)}\ncdr_duree : ${CDR(billsec)}\n" > "/var/log/asterisk/cdr-custom/${STRFTIME(${EPOCH},Europe/Paris,%Y-%m-%d_%H%M%S)}_${CHANNEL(endpoint)}_${CDR(dst)}.wtz")})

https://wiki.asterisk.org/wiki/display/AST/Asterisk+13+Function_CDR

Look towards the end.

Thanks!
This dialplan function worked for me :

exten => h,1,Set(${variablepos}=${SHELL(echo "cdr_numposte : ${CHANNEL(endpoint)}\ncdr_date : ${STRFTIME(${CDR(start,u)},Europe/Paris,%Y-%m-%d %H:%M:%S)}\ncdr_caller : ${CALLERID(num)}\ncdr_called : ${CDR(dst)}\ncdr_forfait : ${CONTEXT}\ncdr_statut : ${CDR(disposition)}\ncdr_duree : ${CDR(billsec)}\n" > "/var/log/asterisk/cdr-custom/${STRFTIME(${EPOCH},Europe/Paris,%Y-%m-%d_%H%M%S)}_${CHANNEL(endpoint)}_${CDR(dst)}.wtz")})
1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.