Follow Techotopia on Twitter

On-line Guides
All Guides
eBook Store
iOS / Android
Linux for Beginners
Office Productivity
Linux Installation
Linux Security
Linux Utilities
Linux Virtualization
Linux Kernel
System/Network Admin
Scripting Languages
Development Tools
Web Development
GUI Toolkits/Desktop
Mail Systems
Eclipse Documentation

How To Guides
General System Admin
Linux Security
Linux Filesystems
Web Servers
Graphics & Desktop
PC Hardware
Problem Solutions
Privacy Policy




8.1. Date/Time/Calendars

There is one command to change both the date and time on a UNIX like system, date, there is also a simple calendar utility, cal. If you are looking to change the time-stamps on files please see Chapter 8


Tells you the date (and the time) and is also used to set the date/time.

To set the date, type date MM:DD:YYYY (American style date) where MM is month, DD is the number of days within the month and YYYY is the year.

For example to set the date to the 1st January 2000 you would type:

date 01:01:2000

To set the time (where the -s option is to set a new time), type:

date -s hh:mm:ss

Another useful option you can use is --date="string" (or -d "string") option to display a date from x days ago or in x days (or x weeks, months, years et cetera). See the examples below.


date --date="3 months 1 day ago"

Will print the date 3 months and 1 day ago from the current date. Note that --date="x month x day ago" and -d "x month x day ago" are equivalent.

date -d "3 days"

The above command will print the date 3 days forward in time from now.

cal Typing cal will give you the calendar of the present month on your screen, in the nice standard calendar format. There are various options to customise the calendar, refer to the info/man page.


cal -y year

Will display a calendar for a specific year, simply use cal -y to print the calendar for the current year.

cal 2 2004

This will display the calendar for February 2004

  Published under the terms of the GNU General Public License Design by Interspire