I am currently learning the zsh and now I wanted to use strftime
but i get:
zsh: command not found: strftime
I think I'm doin' something wrong, since I see people using that function all the time in their dotfiles.
I am currently learning the zsh and now I wanted to use strftime
but i get:
zsh: command not found: strftime
I think I'm doin' something wrong, since I see people using that function all the time in their dotfiles.
strftime
is a C function, I believe date
has all the same functionality on the command line.
See man date
for more.
One uses the --date=STRING
option to specify a date to format instead of getting current time.
strftime
is defined in a zsh
module called datetime
. The zmodload
command loads modules from a colon-separated list of directories in $module_path
.
On my system:
% echo $module_path
/usr/lib/zsh/4.3.10
% ls -l $module_path
drwxr-xr-x 3 root root 4096 2009-11-05 01:03 zsh
% ls -l $module_path/zsh/datetime*
-rw-r--r-- 1 root root 9828 2009-09-10 02:45 /usr/lib/zsh/4.3.10/zsh/datetime.so
% type -a strftime
strftime not found
% zmodload zsh/datetime
% strftime %Y-%m-%d 1271603087
2010-04-18
% type -a strftime
strftime is a shell builtin
% /bin/date -d @1271603087 +%Y-%m-%d
2010-04-18