# How to switch the time?

## ONEEYEMAN

Hi ALL,

I own a nice looking DELL laptop and I did install Gentoo on it without any problems.

My initial time settings was for California (that's where my residence is).

This laptop running GNOME as a desktop environment.

My question here is: what is the way to change the time zone either using shell or inside GNOME?

I will travel with it and will coming back home, which means I will need a current local time...

Thank you.

----------

## frosven

You can copy or symlink any of the available time zones in /usr/share/zoneinfo to /etc/localtime to change your timezone.

```

cp /usr/share/zoneinfo/America/Chicago /etc/localtime

```

----------

## ONEEYEMAN

frosven,

But then I will have 2 links in the /etc/localtime....

First, which one will be active? And second, how do I switch between them?

Thank you.

----------

## Hu

How can one file be two links?  /etc/localtime is a file, not a directory.

----------

## ONEEYEMAN

OK,

But that means I will have to do it every time I leave the timezone.

Is there another solution?

Thank you.

----------

## Hu

Stop traveling so much or switch to GMT.  :Smile:   If you wanted to get fancy, you might be able to rig the system to guess its timezone based on GPS coordinates or a GeoIP service.  Once it works out where it is, it can update /etc/localtime for you.

----------

## ONEEYEMAN

 *Hu wrote:*   

> 
> 
> Stop traveling so much or switch to GMT. 
> 
> 

 

I wish. That is the beauty of being in the military.   :Smile: 

 *Hu wrote:*   

> 
> 
> If you wanted to get fancy, you might be able to rig the system to guess its timezone based on GPS coordinates or a GeoIP service.  Once it works out where it is, it can update /etc/localtime for you.
> 
> 

 

I don't have a GPS system on my laptop. And what is GeoIP?

Thank you.

----------

## danomac

 *ONEEYEMAN wrote:*   

> I don't have a GPS system on my laptop. And what is GeoIP?

 

GeoIP maps geographical locations to IP addresses. I think what was meant is that when you go to another location and get another public IP address, the GeoIP service would look up your current location.

I myself am not aware of any service that does this. One probably exists though.

----------

## ONEEYEMAN

The No 1 example probably would be a mobile phone software. It automatically switches the time when traveling to the different time zone.

However, I don't think anybody implemented this for even Window$.

Thank you.

----------

## paulbiz

If you want to do a user-level timezone (not changing the system time zone) you can edit in .bash_profile and if you're going between the same time zones, maybe you can set up a user for each? It depends on how you use your system I suppose...

----------

## ONEEYEMAN

Hi,

What I'm looking for is the way for GNOME (that's what I have on my laptop) to display the local time wherever I'm located.

Thank you.

[EDIT]

P.S.: I wonder how the mobile phone perform this function?

[/EDIT]

----------

## paulbiz

 *ONEEYEMAN wrote:*   

> Hi,
> 
> What I'm looking for is the way for GNOME (that's what I have on my laptop) to display the local time wherever I'm located.
> 
> Thank you.
> ...

 

I don't have GNOME, but in KDE you can select timezones to view on the clock, and you can simply right-click to select one of your favorite timezones. Probably GNOME has something similar.

As far as I know, the mobile phone gets time data from the cellular network.

----------

## ONEEYEMAN

paulbiz,

Yes, but the question is: how to automate this process, if possible? Cause during install I, for example, struggled with choosing the proper timezone file for USA Pacific Time. I'm not in front of my laptop, but I do remember there are couple of choices to consider...

Thank you.

----------

## paulbiz

Unfortunately I don't think there's a way for it to just "know" where you are located. You'll have to tell it what time zone you're in.

I think you should edit the TIMEZONE setting in /etc/conf.d/clock and avoid the /etc/localtime stuff. The various available time zones on your system (from sys-libs/timezone-data most likely) will be located in /usr/share/zoneinfo and what you set TIMEZONE to should be one of those relative to that path. For example, I live in the Central (USA) time zone and I have mine set to:

```
TIMEZONE="America/Chicago"
```

You can put in all of the timezones you expect to be in and comment out the ones you're not using. Then, when you are relocated, you only need to comment the old time zone and uncomment the new one.

----------

## paulbiz

You can try to go to a site like http://www.ip2location.com/ to see what it detects, if you're not sure where you are or what time zone they use. It's not perfect but it is "usually" right, if you're using a local ISP (not national dial-up number or something like that)

----------

## timeBandit

In GNOME you can go to System | Administration | Time and Date to select the time zone (root password required).

----------

