{"id":16046,"date":"2019-03-18T11:54:02","date_gmt":"2019-03-18T11:54:02","guid":{"rendered":"https:\/\/www.hostinger.com\/tutorials\/?p=16046"},"modified":"2026-03-09T19:19:40","modified_gmt":"2026-03-09T19:19:40","slug":"how-to-set-the-timezone-in-centos","status":"publish","type":"post","link":"\/ng\/tutorials\/how-to-set-the-timezone-in-centos","title":{"rendered":"How to set the timezone in CentOS 7"},"content":{"rendered":"<?xml encoding=\"utf-8\" ?><p>While you are setting up a new server, very often you might have to set the timezone. In certain cases, you might want to change your timezone.<\/p><p>Setting the appropriate timezone on servers is something many of us forget. Setting an inappropriate timezone will impact your server reporting and logs. That&rsquo;s why in this tutorial, we&rsquo;ll show you how to set a timezone in CentOS 7.<\/p><p>Setting the correct time zone for your CentOS based VPS is important for accurately logging timestamps, else you may end up noting a wrong date and timestamp for the incident or error log.<\/p><p>Apart from logging and reporting, another very important factor is the time set for crontabs and automated jobs. Setting an inappropriate time zone may end up running the processes at a different than actually intended time. Luckily if you want to set the timezone in CentOS 7, you&rsquo;ll only need to use a few simple commands!<\/p><p>Overall, not setting the proper time zone won&rsquo;t break your operation, but will definitely improve your workflow and will easily prevent a lack of clarity in your logs.<\/p><p>Let&rsquo;s learn how to set the timezone in CentOS 7.<\/p><div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large\"><a href=\"https:\/\/assets.hostinger.com\/content\/tutorials\/pdf\/Linux-Commands-Cheat-Sheet.pdf\"><img loading=\"lazy\" decoding=\"async\" width=\"2048\" height=\"566\" src=\"https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2022\/11\/Linux-cheat-sheet.png\/public\" alt=\"\" class=\"wp-image-69262\" srcset=\"https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2022\/11\/Linux-cheat-sheet.png\/w=2048,fit=scale-down 2048w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2022\/11\/Linux-cheat-sheet.png\/w=300,fit=scale-down 300w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2022\/11\/Linux-cheat-sheet.png\/w=1024,fit=scale-down 1024w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2022\/11\/Linux-cheat-sheet.png\/w=150,fit=scale-down 150w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2022\/11\/Linux-cheat-sheet.png\/w=768,fit=scale-down 768w\" sizes=\"auto, (max-width: 2048px) 100vw, 2048px\" \/><\/a><\/figure><\/div><p>\n\n\n<div><p class=\"important\"><strong>Important!<\/strong> CentOS Linux 8 has reached it&rsquo;s End of Lifetime (EOL) on 2021-12-31. While CentOS Linux 7 is still supported, it will reach EOL on 2024-06-30. We recommend keeping that in mind when choosing this OS. You can read more about it in their <a href=\"https:\/\/www.centos.org\/centos-linux-eol\/\">official website<\/a>.<\/p><\/div>\n\n\n\n<\/p><h2 class=\"wp-block-heading\" id=\"h-how-to-check-the-set-timezone-in-centos-7\">How to Check the Set Timezone in CentOS 7<\/h2><p>First of all, we need to access our virtual private server using SSH. If you&rsquo;re having trouble, reference the <a href=\"\/ng\/tutorials\/how-to-use-putty-ssh\">PuTTY tutorial<\/a>!<\/p><p>You can check your current time zone by using the <strong>date<\/strong> command as shown below:<\/p><pre class=\"wp-block-preformatted\">date<\/pre><p>This will output the time in the following format:<\/p><pre class=\"wp-block-preformatted\">Fri Mar 15 14:52:20 UTC 2019<\/pre><p>Alternatively, you can use the&nbsp;<strong>timedatectl<\/strong> command. This command can:<\/p><ul class=\"wp-block-list\">\n<li>Review the dates and timestamps<\/li>\n\n\n\n<li>Change the date and time<\/li>\n\n\n\n<li>Setup a timezone for the system<\/li>\n\n\n\n<li>Enable automatic synchronization of the clock based on a remote server<\/li>\n<\/ul><p>The basic command looks like this:<\/p><pre class=\"wp-block-preformatted\">timedatectl<\/pre><p>The output will be as shown below:<\/p><pre class=\"wp-block-preformatted\">Local time: Fri 2019-03-15 14:54:51 UTC\n&nbsp;Universal time: Fri 2019-03-15 14:54:51 UTC\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;RTC time: n\/a\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Time zone: Host (UTC, +0000)\n&nbsp;&nbsp;&nbsp;&nbsp;NTP enabled: n\/a\nNTP synchronized: yes\nRTC in local TZ: no\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;DST active: n\/a<\/pre><p>This contains information such as local time, universal time, and timezone.<\/p><h2 class=\"wp-block-heading\" id=\"h-how-to-list-timezones-in-centos-7\">How to List Timezones in CentOS 7<\/h2><p>Once you have viewed your current timezone, you might want to list all the available timezone options. The below command can be used to list all the timezone options:<\/p><pre class=\"wp-block-preformatted\">timedatectl list-timezones<\/pre><p>You&rsquo;ll get a long list showing all the timezones in alphabetical order. You can refine your search by adding filters using <a href=\"\/ng\/tutorials\/grep-command-in-linux-useful-examples\/\">grep<\/a> patterns. One such example is as shown below:<\/p><pre class=\"wp-block-preformatted\">timedatectl list-timezones | grep Pacific<\/pre><h2 class=\"wp-block-heading\" id=\"h-how-to-set-timezone-in-centos-7\">How to Set Timezone in CentOS 7<\/h2><p>Once you have the list of timezones, you can set the one you prefer. To set the timezone in CentOS 7, you can use:<\/p><pre class=\"wp-block-preformatted\">timedatectl set-timezone America\/Chicago<\/pre><p>You can replace the time zone accordingly in the command above. Over here we can also set a specific time and date. This can be done using the below format:<\/p><pre class=\"wp-block-preformatted\">timedatectl set-time 'YYYY-MM-DD HH:MM:SS'<\/pre><p>For instance, if you want this to be set the time as Mar-16-2019 and the current time as 09:20:00, then you can use:<\/p><pre class=\"wp-block-preformatted\">timedatectl set-time '2019-03-16 09:20:00'<\/pre><p>After making these changes, you can again check the time zone details using <strong>timedatectl<\/strong>.<\/p><h2 class=\"wp-block-heading\" id=\"h-how-to-set-the-hardware-clock-in-centos-7\">How to Set the Hardware Clock in CentOS 7<\/h2><p>A hardware clock is different from the system clock which is managed by the Linux kernel. This is also referred to as the BIOS clock. The hardware clock is enabled once the system is shut down. Using Linux commands, you can set the hardware clock.<\/p><p>To check if the hardware clock is set to local time zone use the below command:<\/p><pre class=\"wp-block-preformatted\">timedatectl | grep local<\/pre><p>This will give output as shown below, which means the hardware clock does not have a timezone specified:<\/p><pre class=\"wp-block-preformatted\">RTC in local TZ: no<\/pre><p>Next, you can set your hardware clock to local time zone using the below command:<\/p><pre class=\"wp-block-preformatted\">timedatectl set-local-rtc 1<\/pre><p><div class=\"protip\">\n                    <h4 class=\"title\">Pro Tip<\/h4>\n                    <p>If you're seeing the error \"Failed to set local RTC: Failed to set RTC to local\/UTC: Input\/output error\" when trying to run this command, try editing the file \/etc\/adjtime\/ by adjusting the third line. You can read more about this error over at <a href=\"https:\/\/stackoverflow.com\/questions\/43121386\/unable-to-set-the-mode-of-the-realtime-clock-to-utc\">Stack Overflow<\/a>.<\/p>\n                <\/div>\n\n\n\n<\/p><p>To revert the changes, you can use:<\/p><pre class=\"wp-block-preformatted\">timedatectl set-local-rtc 0<\/pre><h2 class=\"wp-block-heading\" id=\"h-how-to-perform-clock-synchronization-on-centos-7\">How to Perform Clock Synchronization on CentOS 7<\/h2><p>Network Time Protocol (NTP) is an internet protocol which is commonly used to synchronize system clocks on different computers. The timedatectl command can configure a system&rsquo;s time zone to automatically sync with a remote server using NTP.<\/p><p>To enable this, first, we should have NTP installed on the system. If you don&rsquo;t have this installed on your CentOS device yet, you can do so by installing <a href=\"https:\/\/chrony.tuxfamily.org\/\">Chrony<\/a>:<\/p><pre class=\"wp-block-preformatted\">yum install chrony<\/pre><p>In order to start synchronization with a remote NTP server use the below command:<\/p><pre class=\"wp-block-preformatted\">timedatectl set-ntp true<\/pre><p>In case you want to revert these changes, use the below command. This will disable time synchronization:<\/p><pre class=\"wp-block-preformatted\">timedatectl set-ntp false<\/pre><?xml encoding=\"utf-8\" ?><figure class=\"wp-block-image size-large\"><a class=\"hgr-tutorials-cta hgr-tutorials-cta-vps-hosting\" href=\"\/ng\/vps-hosting\" target=\"_blank\" rel=\"noreferrer noopener\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"300\" src=\"https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2023\/02\/VPS-hosting-banner.png\/public\" alt=\"\" class=\"wp-image-77934\" srcset=\"https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2023\/02\/VPS-hosting-banner.png\/w=1024,fit=scale-down 1024w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2023\/02\/VPS-hosting-banner.png\/w=300,fit=scale-down 300w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2023\/02\/VPS-hosting-banner.png\/w=150,fit=scale-down 150w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2023\/02\/VPS-hosting-banner.png\/w=768,fit=scale-down 768w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure><h2 class=\"wp-block-heading\" id=\"h-conclusion\">Conclusion<\/h2><p>Here we have seen how to set timezone on CentOS 7 as well as how to set system time, date, hardware clock time and synchronize systems using NTP. Setting the right timezone is important for correct logging, automated processes and more!<\/p><p>It&rsquo;s easy to set the timezone on CentOS 7. And yes, to learn about more options, you can always check the manual pages for the timedatectl command.<\/p><p><div class=\"protip\">\n                    <h4 class=\"title\">Learn More About CentOS<\/h4>\n                    <p><a href=\"\/ng\/tutorials\/change-hostname-on-centos-7\/\">How to Change Hostname on CentOS<\/a><br>\n<a href=\"\/ng\/tutorials\/vps\/how-to-install-lamp-stack-centos7\">How to Install LAMP Stack on CentOS<\/a><br>\n<a href=\"\/ng\/tutorials\/how-to-install-ssl-certificate-on-centos-7\">How to Install Let's Encrypt SSL on CentOS<\/a><br>\n<a href=\"\/ng\/tutorials\/how-to-disable-selinux-on-centos-7\/\">How to Disable Selinux on CentOS<\/a><\/p>\n                <\/div>\n<\/p>\n","protected":false},"excerpt":{"rendered":"<p>While you are setting up a new server, very often you might have to set the timezone. In certain cases, you might want to change your timezone. Setting the appropriate timezone on servers is something many of us forget. Setting an inappropriate timezone will impact your server reporting and logs. That&rsquo;s why in this tutorial, [&#8230;]<\/p>\n<p><a class=\"btn btn-secondary understrap-read-more-link\" href=\"\/ng\/tutorials\/how-to-set-the-timezone-in-centos\">Read More&#8230;<\/a><\/p>\n","protected":false},"author":110,"featured_media":145103,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"rank_math_title":"Learn How to Set the Timezone in CentOS 7 \u2013 Complete Beginner's Guide","rank_math_description":"Error logs, chrontabs, automated jobs \u2013 all these functions depend on the correct timezone set on CentOS 7. Learn how to set it correctly!","rank_math_focus_keyword":"set timezone centos","footnotes":""},"categories":[1],"tags":[],"class_list":["post-16046","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-uncategorized"],"hreflangs":[{"locale":"en-US","link":"https:\/\/www.hostinger.com\/tutorials\/what-is-centos","default":0},{"locale":"en-CA","link":"https:\/\/www.hostinger.com\/ca\/tutorials\/how-to-set-the-timezone-in-centos","default":0},{"locale":"en-UK","link":"https:\/\/www.hostinger.com\/uk\/tutorials\/what-is-centos","default":0},{"locale":"en-PH","link":"https:\/\/www.hostinger.com\/ph\/tutorials\/what-is-centos","default":0},{"locale":"en-MY","link":"https:\/\/www.hostinger.com\/my\/tutorials\/what-is-centos","default":0},{"locale":"en-IN","link":"https:\/\/www.hostinger.com\/in\/tutorials\/what-is-centos","default":0},{"locale":"en-AU","link":"https:\/\/www.hostinger.com\/au\/tutorials\/how-to-set-the-timezone-in-centos","default":0},{"locale":"en-NG","link":"https:\/\/www.hostinger.com\/ng\/tutorials\/how-to-set-the-timezone-in-centos","default":0}],"_links":{"self":[{"href":"https:\/\/www.hostinger.com\/ng\/tutorials\/wp-json\/wp\/v2\/posts\/16046","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.hostinger.com\/ng\/tutorials\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.hostinger.com\/ng\/tutorials\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.hostinger.com\/ng\/tutorials\/wp-json\/wp\/v2\/users\/110"}],"replies":[{"embeddable":true,"href":"https:\/\/www.hostinger.com\/ng\/tutorials\/wp-json\/wp\/v2\/comments?post=16046"}],"version-history":[{"count":11,"href":"https:\/\/www.hostinger.com\/ng\/tutorials\/wp-json\/wp\/v2\/posts\/16046\/revisions"}],"predecessor-version":[{"id":145102,"href":"https:\/\/www.hostinger.com\/ng\/tutorials\/wp-json\/wp\/v2\/posts\/16046\/revisions\/145102"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.hostinger.com\/ng\/tutorials\/wp-json\/wp\/v2\/media\/145103"}],"wp:attachment":[{"href":"https:\/\/www.hostinger.com\/ng\/tutorials\/wp-json\/wp\/v2\/media?parent=16046"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.hostinger.com\/ng\/tutorials\/wp-json\/wp\/v2\/categories?post=16046"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.hostinger.com\/ng\/tutorials\/wp-json\/wp\/v2\/tags?post=16046"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}