Printf %T not working

Dear All,

this script was working well enough few days back. Now it started acting up.
Could anyone please throw some lights about what may be the reason for it's not working.

ts=$( printf "%(%s)T" "now" )

under debug mode this is what I get

printf "%(%s)T" "now"
++ printf '%(%s)T' now
test.sh: line 2: printf: `(': invalid format character
+ ts=

my OS is

x86_64 GNU/Linux

and shell is

/bin/ksh93

However more strange thing is if I'm running same line on the command prompt not thru any shell script then this same line works like charm.

> ts=$( printf "%(%s)T" "now" )
> echo $ts
1395415413

What does the hashbang line of your script look like?

it's #!/bin/ksh93

And how do you run the script exactly?

printf usually wants a %% for the format specification for a single % character - that is what the error says, anyway.

The command which printf; type printf
would be more informative - are you using /usr/bin/printf or the ksh builtin?

Example:

# which printf
/usr/bin/printf
# type printf
printf is a shell builtin

If you changed your .profile recently or modified your environment variables, then this is the place to look first.