How to change date, time and timezone

By default, your CentOS or Redhat Server maybe don’t have correct time or timezone. So we have to do the configuration for that.

Step 1: Check your current time

[root@ithelpblog ~]# date
Wed Apr 6 10:07:12 UTC 2016

[root@ithelpblog ~]

#

Step 2: Get the list for timezone

[root@ithelpblog ~]# cd /usr/share/zoneinfo/

[root@ithelpblog zoneinfo]

# ls
Africa Australia Cuba Etc GMT-0 Indian Kwajalein Navajo posix ROK UTC
America Brazil EET Europe GMT+0 Iran Libya NZ posixrules Singapore WET
Antarctica Canada Egypt GB Greenwich iso3166.tab MET NZ-CHAT PRC Turkey W-SU
Arctic CET Eire GB-Eire Hongkong Israel Mexico Pacific PST8PDT UCT zone.tab
Asia Chile EST GMT HST Jamaica MST Poland right Universal Zulu
Atlantic CST6CDT EST5EDT GMT0 Iceland Japan MST7MDT Portugal ROC US

[root@ithelpblog zoneinfo]

#

Step 3: We will use timezone in one of the State of America: Chicago

[root@ithelpblog zoneinfo]# cd /usr/share/zoneinfo/America/

[root@ithelpblog America]

# ls
Adak Boise Dawson Guayaquil Louisville Montreal Rainy_River St_Lucia
Anchorage Buenos_Aires Dawson_Creek Guyana Lower_Princes Montserrat Rankin_Inlet St_Thomas
Anguilla Cambridge_Bay Denver Halifax Maceio Nassau Recife St_Vincent
Antigua Campo_Grande Detroit Havana Managua New_York Regina Swift_Current
Araguaina Cancun Dominica Hermosillo Manaus Nipigon Resolute Tegucigalpa
Argentina Caracas Edmonton Indiana Marigot Nome Rio_Branco Thule
Aruba Catamarca Eirunepe Indianapolis Martinique Noronha Rosario Thunder_Bay
Asuncion Cayenne El_Salvador Inuvik Matamoros North_Dakota Santa_Isabel Tijuana
Atikokan Cayman Ensenada Iqaluit Mazatlan Ojinaga Santarem Toronto
Atka Chicago Fortaleza Jamaica Mendoza Panama Santiago Tortola
Bahia Chihuahua Fort_Wayne Jujuy Menominee Pangnirtung Santo_Domingo Vancouver
Bahia_Banderas Coral_Harbour Glace_Bay Juneau Merida Paramaribo Sao_Paulo Virgin
Barbados Cordoba Godthab Kentucky Metlakatla Phoenix Scoresbysund Whitehorse
Belem Costa_Rica Goose_Bay Knox_IN Mexico_City Port-au-Prince Shiprock Winnipeg
Belize Creston Grand_Turk Kralendijk Miquelon Porto_Acre Sitka Yakutat
Blanc-Sablon Cuiaba Grenada La_Paz Moncton Port_of_Spain St_Barthelemy Yellowknife
Boa_Vista Curacao Guadeloupe Lima Monterrey Porto_Velho St_Johns
Bogota Danmarkshavn Guatemala Los_Angeles Montevideo Puerto_Rico St_Kitts

[root@ithelpblog America]# cp /usr/share/zoneinfo/America/Chicago /etc/localtime

Step 4: Modify the date/time on Centos 7

date MMDDhhmmYYYY

  • MM: two digit month number
  • DD: two digit date
  • hh: two digit hour (24 hour system)
  • mm: two digit minute
  • YYYY: four digit of year

Step 5: You can use ntp (network time protocol) to auto sync the time in your Centos

yum install ntp

ntpdate pool.ntp.org

About Damon Luong

San Jose, California
This entry was posted in My Linux. Bookmark the permalink.