As a System Administrator  is an important Keeping Date and Time up to date  on your systems. Most of application running, getting server logs, accessing time, logging time to get accurate timing information to running properly. Also do you need to refer information based on time.

This post have few command to update date and time in your Linux system.

Show current date and timezone:

The date command is helpful to shows your current system time. 

#  date
Thu Jul 29 18:46:53 IST 2015


Change Time Format:

In Linux, you can  change the date and time format:
 
#  date +'%Y%m%d %H%M' --set='20150729 1859'
20150729 1859


%Y - Year
%m - Moth
%d - Day
%H - Hour
%M - Minute


Update TimeZone (TZ)Environment Variable :

The following command is use to change TimeZone format, Use TZ variable format require to update.

We have few examples to update system time based on country based,

Malaysia (MY)

Asia/Kuala_Lumpur     peninsular Malaysia
Asia/Kuching         Sabah & Sarawak

INDIA (IN)
Asia/Kolkata        India

United States(US)

America/Los_Angeles    

How to set timezone to IST:
 
# export TZ=Asia/Kolkata

# date
Wed Jul 29 20:02:10 IST 2015

How to set timezone to MYT:
 
# export TZ=Asia/Kuala_Lumpur 

# date
  
Wed Jul 29 22:29:59 MYT 2015

How to set timezone to PDT:
 
# export TZ=America/Los_Angeles

# date
Wed Jul 29 07:37:07 PDT 2015


Increase and Decrease Months, Weeks, Minutes.

The below commands are you can  (+) increase or (-) decrease date or time by a number of days, weeks, months or years, and seconds,
 
# date
Wed Jul 29 19:00:06 IST 2015
# date --set='+10 minutes'
Wed Jul 29 19:10:11 IST 2015
# date --set='-9 minutes'
Wed Jul 29 19:01:25 IST 2015
# date --set='+2 weeks'
Wed Aug 12 19:02:17 IST 2015
# date --set='-2 weeks'
Wed Jul 29 19:02:32 IST 2015
# date --set='+1 months'
Sat Aug 29 19:02:56 IST 2015
# date --set='-1 months'
Wed Jul 29 19:03:02 IST 2015
# date --set='+1 months +2 weeks +3 minutes'
Sat Sep 12 19:08:06 IST 2015
# date --set='-1 months -2 weeks -3 minutes'
Wed Jul 29 19:05:13 IST 2015


Hardware clock :

The hwclock command is get and display your hardware system time, date, year, month.
 
# hwclock 
or
# hwclock --show
Wed 29 Jul 2015 07:07:58 PM IST  -0.739991 seconds