Date

From Wsms

Jump to: navigation, search

Note: This page should be titled date (all lowercase). It is Date due to technical limitations of Mediawiki.

date

date is a linux command to retrieve the current date and time.

usage

Date has some cool formatting options for the output

Print the date in the default format:

ggeller@roosevelt:~$ date
Mon Oct  6 10:01:51 PDT 2008

Print just the year:

ggeller@roosevelt:~$ date +%Y
2008

Print the year, month, day, minutes and hours:

ggeller@roosevelt:~$ date +%Y%m%d-%H%MHRS
20081006-1005HRS

Make an empty file with a name containing a time-stamp:

ggeller@roosevelt:~$ touch notes-`date +%Y%m%d-%H%MHRS`
ggeller@roosevelt:~$ ls -l notes-20081006-1007HRS 
-rw-r--r-- 1 ggeller ggeller 0 2008-10-06 10:07 notes-20081006-1007HRS

see also

man date

Personal tools