klenwell information services : BashDate

Bash Date

return to DevBash

Usage

Basic
$ date
Thu Jul 22 12:24:01 PDT 2010

$ date "+%Y-%m-%d %H:%M:%S"
2010-07-22 12:24:23


In filename (e.g. making a backup):
$ touch /tmp/original.txt
$ cp /tmp/original.txt /tmp/original.$(date +%Y%m%d).txt


Date Arithmetic
klenwell@home:~$ date
Tue Apr 12 15:42:56 PDT 2011
klenwell@home:~$ date --date "now +20 minutes"
Tue Apr 12 16:03:01 PDT 2011
klenwell@home:~$ date --date "now -20 minutes"
Tue Apr 12 15:23:04 PDT 2011


References

http://stackoverflow.com/questions/967780/bash-date-time-arithmetic