How do I view and set date under UNIX operating systems?
The date command under UNIX display date. It is also used to set date and time. You must be the super-user (root) to change the date and time.
UNIX Date Command Syntax
date date "+format"
Task: Display Current Date and Time
Type the following command:
date
Sample outputs:
Tue Oct 27 15:35:08 CDT 2009
Task: Set The Current Time
To set the current time to 05:30:30, enter:
date 0530.30
Task: Set Date
Set the date to Oct 25, 12:45 a.m., enter:
date 10250045
Another example - set the current date and time to Oct 15, 2009 04:30 you type:
date --set="20091015 04:30"
Task: Generating Output
Type the following command:
date '+DATE: %m/%d/%y%nTIME:%H:%M:%S'
Sample outputs:
DATE: 10/27/09 TIME:15:50:44
Try the following examples:
date "+%m/%d/%y" date "+%Y%m%d" date +'%-4.4h %2.1d %H:%M'
Unix Command Help
Type the following command to read the date command man page:
man date
Featured Articles:
- 20 Linux System Monitoring Tools Every SysAdmin Should Know
- My 10 UNIX Command Line Mistakes
- 10 Greatest Open Source Software Of 2009
- Top 5 Email Client For Linux, Mac OS X, and Windows Users
- Top 20 OpenSSH Server Best Security Practices
- Top 10 Open Source Web-Based Project Management Software
- Top 5 Linux Video Editor Software
Want to read Linux tips and tricks, but don't have time to check our blog everyday? Subscribe to our daily email newsletter to make sure you don't miss a single tip/tricks. Subscribe to our weekly newsletter here!
- Email FAQ to a friend
- Download PDF version
- Printable version
- Comment RSS feed
- Last Updated: 02/15/10



{ 0 comments… add one now }