Quantcast
Channel: VOIP-info.org Wiki Changes
Viewing all articles
Browse latest Browse all 5767

Asterisk func strftime

$
0
0

STRFTIME

Formats the datetime

Synopsis

STRFTIME([<epoch>][,[<timezone>][,<format>]])

Description

Formats the time specified by <epoch>, localized to <timezone>. The format comes directly from the underlying C function strftime(3). If <epoch> is not specified, defaults to the current time. <timezone> likewise defaults to the timezone on the host computer. A list of possible timezones may be obtained from the directory listing in /usr/share/zoneinfo. The default format is %c.

This example sets the variable CallTime to the correct local time string in the format Unix utilities like `touch` want, i.e. YYYYMMDDhhmm:

exten => s,n,set(CallTime=${STRFTIME(${EPOCH},GMT+8,%C%y%m%d%H%M)})

Format String

This will vary from distribution to distribution, as their are different implementations of strftime. If these values do not work correctly on your system, please consult the man page for your implementation of strftime (you can do this by running `man 3 strftime` from your server's command line).

The following values are based on an <epoch> value of 1185130650 (obtained via the ${EPOCH} variable) at -0400 or Eastern Daylight Time (EDT). The output of the Unix `date` command is:

[root@asterisk]# date
Sun Jul 22 14:57:30 EDT 2007

These format strings are from the CentOS 5.0 man page for strftime(3):

Format String Description Example
%aThe abbreviated weekday name according to the current locale.Sun
%AThe full weekday name according to the current locale.Sunday
%bThe abbreviated month name according to the current locale.Jul
%BThe full month name according to the current locale.July
%cThe preferred date and time representation for the current locale.Sun Jul 22 14:57:30 2007
%CThe century number (year/100) as a 2-digit integer.20
%dThe day of the month as a decimal number (range 01 to 31).22
%DEquivalent to %m/%d/%y. (Yecch — for Americans only. Americans should note that in other countries %d/%m/%y is rather common. This means that in international context this format is ambiguous and should not be used.)07/22/07
%eLike %d, the day of the month as a decimal number, but a leading zero is replaced by a space.22
%FEquivalent to %Y-%m-%d (the ISO 8601 date format).2007-07-22
%GThe ISO 8601 year with century as a decimal number. The 4-digit year corresponding to the ISO week number (see %V). This has the same format and value as %y, except that if the ISO week number belongs to the previous or next year, that year is used instead.2007
%gLike %G, but without century, i.e., with a 2-digit year (00-99).07
%hEquivalent to %b.Jul
%HThe hour as a decimal number using a 24-hour clock (range 00 to 23). ...

Viewing all articles
Browse latest Browse all 5767

Trending Articles