LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   Change timezone using date (https://www.linuxquestions.org/questions/linux-general-1/change-timezone-using-date-373263/)

davholla 10-15-2005 05:18 AM

Change timezone using date
 
I know that date -u sets timezone to be GMT, but I want to set it to be UK time how do I do that ?

TigerOC 10-15-2005 05:37 AM

date -u sets the clock to UTC not gmt. You'll find info on setting time zones and clocks here .

homey 10-15-2005 08:44 AM

Note: I'm using US/Eastern zone
You should be able to find your zone in /usr/share/zoneinfo

From what I found in google, using the date command for timezone should look like this.
date -s "10/15/2005 09:40:00 EDT" but that doesn't seem to work on my FC4 box.

I was able to change it with the command: export TZ="US/Eastern"

I found it to be just as easy to edit the /etc/sysconfig/clock, so this is my prefered method...
ZONE="America/New_York"
UTC=false
ARC=false

Then, I ran these commands:
rm -f /etc/localtime
ln -sf /usr/share/zoneinfo/US/Eastern /etc/localtime
date -s "10/15/2005 09:40:00"
/sbin/hwclock --systohc

You may have to log out and back in to see the correct time.

davholla 10-15-2005 09:52 AM

Quote:

Originally posted by homey

Then, I ran these commands:
rm -f /etc/localtime
ln -sf /usr/share/zoneinfo/US/Eastern /etc/localtime
date -s "10/15/2005 09:40:00"
/sbin/hwclock --systohc

You may have to log out and back in to see the correct time.

Thanks I did the above only using
ln -sf /usr/share/zoneinfo/GB /etc/localtime


The only strange thing after logging in and out I get the right date but it is GMT which is not correct - it should be BST.

homey 10-15-2005 11:37 AM

You may end up using a config tool in yast or maybe the command: timeconfig
or even export TZ="GB"

davholla 10-16-2005 03:47 AM

Actually I am using Knoppix 3.9 installed to my hard drive- I must change that.

The annoying thing is that after rebooting my time zone has been reset back to EDT - how do I stop that.
Also bizarelly the date is incorrect ! It thinks that today is the 11th of March 2006

homey 10-16-2005 07:29 AM

Here are a couple more time zone tools.
Code:

zdump US/Eastern
or tzconfig

Here is the command for setting the date and time.
Code:

date -s "10/16/2005 08:30:00"
or  ``date 10160830


davholla 10-16-2005 02:16 PM

Thanks I think zdump worked. I will have to see tomorrow.

davholla 10-17-2005 02:39 PM

The change is not permanent
 
After turning on the pc, I get the wrong date again.

Also tzconfig does not work, my timezone is london but date says different.
Code:

tzconfig
Your current time zone is set to Europe/London
Do you want to change that? [n]: n
Your time zone will not be changed
root@Knoppix:~# date
Mon Oct 17 20:40:16 EDT 2005


homey 10-17-2005 03:32 PM

How about if you change
ln -sf /usr/share/zoneinfo/GB /etc/localtime

to this
rm -f /etc/localtime
ln -sf /usr/share/zoneinfo/Europe/London /etc/localtime

davholla 10-21-2005 08:16 AM

Sadly no
 
Quote:

Originally posted by homey
How about if you change
ln -sf /usr/share/zoneinfo/GB /etc/localtime

to this
rm -f /etc/localtime
ln -sf /usr/share/zoneinfo/Europe/London /etc/localtime

It only works until i have to turn my pc off and on again (ie go to bed).

homey 10-21-2005 08:42 AM

Quote:

tzconfig
Your current time zone is set to Europe/London
Do you want to change that? [n]: n
Maybe you can fool it by selecting "yes" , change it to somewhere else then back to Europe/London.

davholla 10-21-2005 08:48 AM

Good idea I will try that tonight

davholla 10-22-2005 09:33 AM

Well it worked - until I turned it back on and it was the same as before.
Thanks for the help. Any more ideas ?

homey 10-22-2005 09:51 AM

Quote:

It only works until i have to turn my pc off and on again (ie go to bed).
There's your problem! True Linux geeks never go to bed! :)

Sorry, I'm fresh out of ideas. :(

Redhat / Fedora has a file where the info is stored: /etc/sysconfig/clock
ZONE="America/New_York"
UTC=false
ARC=false

I don't know if Knoppix / Debian has anything similar.


All times are GMT -5. The time now is 11:36 AM.