Date
|
From Linuxconfig.org
.. back to the list of Linux Commands
Name
date - print or set the system date and time
Synopsis - man page
date [OPTION]... [+FORMAT] date [-u|--utc|--universal] [MMDDhhmm[[CC]YY][.ss]]
Frequently used options
-u, --utc, --universal
print or set Coordinated Universal Time
+%F full date; same as %Y-%m-%d
Examples
date command is used to set up and display time. By typing date command without any options and arguments date displays current time:
$ date
date command can also be used to set time. However this require superuser permissions. To set time to 20th March 2010 23:45:28 we can issue command:
# date 032023452010.28
Date command is often used with connection to bash scripting for example to create simple backup scripts:
#!/bin/bash OF=myhome_directory_$(date +%Y%m%d).tar.gz tar -czf $OF /home/linuxconfig
Or we can do something like this:
$ echo "Today is `date +%A` `date +%e`th of `date +%B` `date +%G` which is \ `date +%j`th day since 1th of January `date +%G`"

















