We have tested the following commands with ksh93 printf in many AIX 5.3/6.1 systems, but they all failed with the same result.

Why is that?

# oslevel -s                               
# ksh93 -c 'echo ${.sh.version}'
Version M-12/28/93e
# ksh93 -c 'printf "%T\n" "now"'      
ksh93[1]: printf: T: unknown format specifier
  • does printf '%(YY)T' work as expected? If not, your version of ksh does not have ksh93h features. Probably too old. Jul 24, 2023 at 13:14
  • 2
    ksh93e is ancient. Jul 24, 2023 at 13:20
  • I mean the good thing is, you can still printf 'date is %s\n' $(date '+%Y-%m-%d') instead of printf 'date is %(%Y-%m-%d)T\n' and get the same result. Jul 24, 2023 at 13:24
  • 2
    @MarcusMüller As date just prints plain text verbatim anyway, date '+date is %Y-%m-%d' also works (regardless of shell). Jul 24, 2023 at 16:45
  • 1
    @Paul_Pedant sure, but you might want one of the other features of printf on that thing :) Jul 24, 2023 at 17:42

2 Answers 2


%T was added to ksh's printf in ksh93h released in 1999

Note the h suffix (where you have e) which indicates the version of ksh93.

The latest release of ksh93 by AT&T was ksh93u+ released in 2012. Development carries on as a community effort at https://github.com/ksh93/ksh with the latest release as of writing being ksh93u+m 1.0.6 from June 2023 and the one you'll likely want to switch to as it comes with hundreds of bug fixes.

Your ksh93e is ancient, released in 1996, even more ancient than AIX 5.3 or 6.1 (both EOL AFAICT).

If you're lucky, the date builtin was included in your build of ksh93 (I don't know if it was possible in ksh93e though as it was before ksh93 was made opensource), in which case you could do:

builtin date
date -d now '+the format you need: %FT%T%z for instance'

(with the date -d accepting the same date/time specification as printf %T does, not documented but you can find some examples in that test file shipped with the ast-open source) and instead of:

printf '%(format)T %<other-directive>' \
  some-time-spec \

You'd do:

builtin date
printf '%s %<other-directive>' \
  "${ date -d some-time-spec +format; }" \

Note that bash added a %T to its printf in 4.2 (2011) which implements a subset of ksh93's functionality in an incompatible way.

It doesn't support parsing dates such as now like ksh93 does. The only supported arguments are:

bash ksh93 equivalent description
123456789 #123456789 arbitrary epoch time¹
-1² now or '' current time
-2 none³ time the shell was started

zsh added a strftime builtin to format dates in 4.1.1 released in 2003 which should be contemporary to AIX 5.3 and may be another option for you.

For the current time in a format similar to that of ksh93's default %T one:

$ zmodload zsh/datetime
$ strftime '%a %b %e %T %Z %Y' $EPOCHSECONDS
Mon Jul 24 15:10:15 BST 2023

Parsing times with strftime -r (using strptime()) was only added in 4.3.3 (2007) though (contemporary to AIX 6.1).

¹ Note that in bash that can only be an integer number while in ksh93, that can have a decimal part (with . as radix character regardless of the locale).

² since 5.0, bash has a $EPOCHSECONDS special variable (copied from zsh) which can also be used there for the current time.

³ though you could always record that time at the start of your script with starttime=${ printf '#%(%s.%N)T' now; }

  • 1
    aaaargh, bash, why are you so… bash?! Jul 24, 2023 at 14:34

For AIX printf command %T is not a valid format specification. Please check the manual. Valid are
a, A, d, i, o, u, x, X, f, F, e, E, g, G, c, s, b

  • That link is about the standalone printf utility. The OP is talking about the printf builtin of ksh93 where a %T was added in version ksh93h so would hopefully be available in AIX 7.2. printf --man in ksh93 to see the manual of the builtin. Jul 24, 2023 at 13:30
  • @StéphaneChazelas, on this page I see text: "The printf command works in a similar manner as the printf() C library routine. See the printf command." ibm.com/docs/en/aix/7.2?topic=shell-enhanced-korn-ksh93 Jul 24, 2023 at 14:55
  • If you want a man page for ksh93's printf, run ksh93 -c 'printf --nroff 2> printf.1', you won't find one online. What time specifications it supports (which is very wide) is hardly documented. Jul 24, 2023 at 15:03
  • (you can find some examples at github.com/att/ast/blob/master/src/cmd/tests/date.dat though) Jul 24, 2023 at 15:10
  • 1
    @StéphaneChazelas, IBM have own way to do the things and I am not sure they will implement something new if there is no real big demand. Unfortunately I have no access to AIX to check my assumptions. :) Jul 24, 2023 at 15:21

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .