Untitled Document
date Command

date command is used to print the current system date with different format specifier options .Most importantly it is used to set the system date .We can even use date with command substitution (``) in script to create files with execution date and time for maintaining logs .

1. Basic Example -

Run date command without any option-

   date
   o/p - Fri Feb 12 05:51:34 EST 2016

2. Set the system date and time to - "11/20/2016 12:45:00"

This will set system date to Novemeber 20,2016 12:45 pm

  date -s "11/20/2016 12:45:00"
Only administrator or super user can set system date . No other user or normal user can invoke this command .

3.Print the date output in below format -

DATE:15/02/2015 TIME:

 date "+DATE : %d/%m/%Y %n TIME : %H:%m:%s"

4.Create the file having name as today's date using date-

 cat > `date "+%d/%m/%Y"`
 Hello User 
 You have Create a file using
 cat command having name created with date command 
Untitled Document