[Asterisk-Users] Re: Strange variable chopping from AGI's

James H. Cloos Jr. cloos at jhcloos.com
Mon Dec 8 17:12:06 MST 2003


James Golovich <james at wwnet.net> wrote:

>Change your sprintf to:
>$hirestime = sprintf("%d%06d", $seconds, $microseconds);
>This will make it so that microseconds will always be 6 characters long

>or change it to something like:
>$hirestime = sprintf("%d.%d", $seconds, $microseconds);
>So there will always be a decimal place between seconds and microseconds.

You still need to %06d in the second example, so that should read:

# either:
$hirestime = sprintf("%d%06d", $seconds, $microseconds);
# or:
$hirestime = sprintf("%d.%06d", $seconds, $microseconds);

depending on whether you want $hirestime to be in seconds or mcroseconds.

-JimC




More information about the asterisk-users mailing list