HOWTO: Change the Time Zone
I have some of my websites running on Virtual Private Servers (VPS) over on Unixshell. For months now my server’s time has been 2 hours ahead of my time here in Calgary. I didn’t really mind that until I started running Citadel, my groupware server, off one of those VPSs. It’s really annoying to have all of you appointments show up 2 off from when they should.
I tried changing the date using the date command, but it would never stick. Then I realized that I probaby have to change the actual time zone of the box. I found a great little tutorial on how to change the time zone which you can find here.
In a nutshell, there is a file called /etc/localtime. It’s a binary file which you can’t read, but that’s OK because you don’t have to. Take a look in the /usr/sharezoneinfo directory. Hopefully, you’ll see a file for each time zone on the planet. In order to make your timezone the server’s time date,zone - copy the file in /usr/share/zoneinfo that reflects your timezone to /etc/localtime. Type date, and you should see your new time.
Too easy, eh?
I’ve only tried this on a Debian 3.1 box. I’m not 100% sure that it’s the same procedure on other systems.
Related Stories
POSTED IN: How To
3 opinions for HOWTO: Change the Time Zone
eric
Jun 27, 2006 at 12:33 am
Jon, do you run cPanel or WHM on the server, or do you administer only via SSH?
I run a few cPanel servers and you can make this change to the server via the WHM (Web Host Manager) control panel, depending on the access that your provider has given you.
Some companies only grant limited access to WHM functionality to help new users from doing something they could regret.
Thanks for the tip, though, I’m trying to spiff up my ninja command line skills.
Jon
Jun 27, 2006 at 4:59 am
Hey eric,
No, nothing like that. A while ago I did want to install cPanel, but it’s designed in such a way that it pretty much has to be the first thing installed on a box. I didn’t feel like re-doing my entire server just to get cPanel, though, so I pssed. The next server I set up will have it, though.
Tom
Jul 2, 2006 at 2:05 am
Hi,
I just saw this and thought I’d let you know the /etc/localtime and /usr/share/zoneinfo files are part of glibc so they should work on any linux distro and probably most other unices (sp?). Also if you’re unsure of the name of you timezone you can use the tzselect utility to figure it out. It’s text-based but it works and it’s also part of glibc so it should be pretty universal.
~Tom
Have an opinion? Leave a comment: