Pi-n-Mash
Posts: 19
Joined: Thu Apr 19, 2012 5:19 pm

Re: Setting the Timezone

Thu Apr 19, 2012 6:30 pm

I'm surprised nobody has asked this, but I can't find it!

To set the timezone on Debian, type tzselect at a terminal prompt, and answer the questions. For the UK, the answers are 8 (Europe), 8 (Britain) and 1 (yes).

The only annoying thing is that you have to put it into your profile and the easiest way to do this is to type the following:

echo "TZ='Europe/London'; export TZ" >.profile

Note the mixture of quotes.

Perhaps nobody cares about the time on their computer, but I do!

TheUnknownCylon
Posts: 3
Joined: Wed Apr 18, 2012 2:38 pm

Re: Setting the Timezone

Thu Apr 19, 2012 6:39 pm

In arch Linux you can get your timezone with tzselect as well. To apply it on your entire system, you should open /etc/rc.conf in your favorite editor (e.g. type in your console: sudo nano /etc/rc.conf). In this file find the line

TIMEZONE="Europe/London"

, and replace "Europe/London" with your timezone.

Joe Schmoe
Posts: 4277
Joined: Sun Jan 15, 2012 1:11 pm

Re: Setting the Timezone

Thu Apr 19, 2012 6:52 pm

As I mentioned over in the "keyboard" thread, there are several competing programs for this (timezone setting).  I mentioned "tzset" and "tzconfig"; I had forgotten about "tzselect".  So, that makes 3.

I think tzconfig is the best, because it actually does it the right way (that is, creates the /etc/timezone file for you).  Of the others, one simply doesn't work (generates message that says "Don't use this anymore") and the other just tells you what you need to put in your .profile (or whatever).  In any case, the point is that the TZ environment variable method is "deprecated" now.

It is also possible that I'm not quite remembering this right - and that one or the other of these programs actually tells you to do: dpkg reconfigure something

in which case, that's the right way to do it...
And some folks need to stop being fanboys and see the forest behind the trees.

(One of the best lines I've seen on this board lately)

User avatar
jojopi
Posts: 2999
Joined: Tue Oct 11, 2011 8:38 pm

Re: Setting the Timezone

Thu Apr 19, 2012 8:06 pm

The correct way to set the system timezone is to clobber /etc/localtime.  This should work across most distros.sudo cp /usr/share/zoneinfo/Europe/London /etc/localtime
Filename TAB completion will help you to find the right file.

Pi-n-Mash
Posts: 19
Joined: Thu Apr 19, 2012 5:19 pm

Re: Setting the Timezone

Thu Apr 19, 2012 8:25 pm

Well, what a mess for such a simple thing! Almost enough to send me back to Windows

Joe Schmoe
Posts: 4277
Joined: Sun Jan 15, 2012 1:11 pm

Re: Setting the Timezone

Thu Apr 19, 2012 10:11 pm

That's funny, Jojo.  Because it's like: If you give the "low level" (e.g., just copy or edit this file and you're done) way of doing some system configuration task, all the "GUI's are good!" folks will come back at you asking how to do it with just clicking.

If you give the GUI (or, in this case, pseudo-GUI) way to do it (as I did), then they come back with "Just copy this file"...

(heh heh)
And some folks need to stop being fanboys and see the forest behind the trees.

(One of the best lines I've seen on this board lately)

u4ia
Posts: 2
Joined: Wed Apr 18, 2012 10:22 pm

Re: Setting the Timezone

Fri Apr 20, 2012 2:05 am

In debian you can simply:

sudo dpkg-reconfigure tzdata

User avatar
jojopi
Posts: 2999
Joined: Tue Oct 11, 2011 8:38 pm

Re: Setting the Timezone

Fri Apr 20, 2012 10:12 am

Joe Schmoe said:

If you give the GUI (or, in this case, pseudo-GUI) way to do it (as I did), then they come back with "Just copy this file"...
It was not actually my intent to promote CLI methods over GUI ones, but to promote methods that change /etc/localtime over those mentioned that did not.  (And to be fair, you had not spelled out a fully working solution at all.)

As it turns out, arch clobbers /etc/localtime on every boot.  So the only correct method on that system is to edit /etc/rc.conf !

For completeness, the GUI/TUI method on fedora is "system-config-date".

User avatar
Ray_GTI-R
Posts: 96
Joined: Fri Mar 09, 2012 1:21 am
Contact: Website

Re: Setting the Timezone

Sat Jul 07, 2012 3:18 am

OK, read these and other procedures, fragmented but got there eventually.
My solution:-
When you switch on your RPi with a fresh install of the original Debian release and a working Internet connection the date, time and timezone is automatically set ( probably wrongly - this drove me up the pole everytime I switched on).
My permanent-for-me procedure ...
I located the .profile file in /home/pi ... method irrelevant
I opened it (to edit it). ... method irrelevant
I appended .... TZ='Europe/London'; export TZ ... to the .profile file ... method irrelevant
I saved the .profile file. ... method irrelevant
I logged out of Xwindows 'coz that's where I did all this via File Manager & Leafpad ;) but that's not important ... method irrelevant, remember :roll:
I shut down the RPi (I always enter:- sudo shutdown -h now before I unplug the power cord.

Cold-booted 6 times and it worked OK every time. :D
PS - ignore the bizarre bootup date/time/timezone messages before you start the GUI e.g., XwindowsPPS
Well, what a mess for such a simple thing! Almost enough to send me back to Windows
I couldn't agree more. Six pretty complex steps FFS :cry:
I realise this is addressed in the Beta release. Haven't tried that yet ;)
.

savesteve
Posts: 1
Joined: Wed Jul 18, 2012 9:00 am

Re: Setting the Timezone

Wed Jul 18, 2012 9:02 am

I use the debian image and I just ran:

Code: Select all

dpkg-reconfigure tzdata
and done...

kazz888
Posts: 1
Joined: Thu Jan 24, 2013 1:09 pm

Re: Setting the Timezone

Fri Feb 15, 2013 2:02 pm

there is an easier way to do it, is is explained here
http://elinux.org/R-Pi_Troubleshooting# ... _incorrect
;)

GuilTV
Posts: 1
Joined: Sun Apr 21, 2013 12:42 am

Re: Setting the Timezone

Thu Jul 18, 2013 7:43 pm

sudo raspi-config
and configure your pi to your heart's content...including timezones.

parapac
Posts: 14
Joined: Wed Jul 23, 2014 12:17 pm

Re: Setting the Timezone

Sun Sep 07, 2014 10:40 am

I just did this

sudo dpkg-reconfigure tzdata

And got

Please select the geographic area in which you live. Subsequent configuration questions will
narrow this down by presenting a list of cities, representing the time zones in which they are
located.

1. Africa 5. Arctic Ocean 9. Indian Ocean 13. None of the above
2. America 6. Asia 10. Pacific Ocean
3. Antarctica 7. Atlantic Ocean 11. System V timezones
[More] 13

4. Australia 8. Europe 12. US

Geographic area: 8


Please select the city or region corresponding to your time zone.

1. Amsterdam 11. Bsingen 21. Kaliningrad 31. Monaco 41. San Marino 51. Vaduz
2. Andorra 12. Chisinau 22. Kiev 32. Moscow 42. Sarajevo 52. Vatican
3. Athens 13. Copenhagen 23. Lisbon 33. Nicosia 43. Simferopol 53. Vienna
4. Belfast 14. Dublin 24. Ljubljana 34. Oslo 44. Skopje 54. Vilnius
5. Belgrade 15. Gibraltar 25. London 35. Paris 45. Sofia 55. Volgograd
6. Berlin 16. Guernsey 26. Luxembourg 36. Podgorica 46. Stockholm 56. Warsaw
[More] 22

7. Bratislava 17. Helsinki 27. Madrid 37. Prague 47. Tallinn 57. Zagreb
8. Brussels 18. Isle of Man 28. Malta 38. Riga 48. Tirane 58. Zaporozhye
9. Bucharest 19. Istanbul 29. Mariehamn 39. Rome 49. Tiraspol 59. Zurich
10. Budapest 20. Jersey 30. Minsk 40. Samara 50. Uzhgorod

Time zone: 22



Current default time zone: 'Europe/Kiev'
Local time is now: Sun Sep 7 13:07:09 EEST 2014.
Universal Time is now: Sun Sep 7 10:07:09 UTC 2014.

pi@raspberrypi

Trouble is its out, its actually 1340

CMontcalm
Posts: 1
Joined: Tue Feb 02, 2016 3:19 am

Re: Setting the Timezone

Tue Feb 02, 2016 3:23 am

jojopi wrote:The correct way to set the system timezone is to clobber /etc/localtime. This should work across most distros.sudo cp /usr/share/zoneinfo/Europe/London /etc/localtime
Filename TAB completion will help you to find the right file.
I'm quite new to Linux and I wanted to say that this answer was very strait forward and worked perfectly.
Thank You

jcoutch
Posts: 2
Joined: Sat Nov 07, 2015 5:27 pm

Re: Setting the Timezone

Tue Sep 06, 2016 5:27 pm

jojopi wrote:The correct way to set the system timezone is to clobber /etc/localtime.  This should work across most distros.sudo cp /usr/share/zoneinfo/Europe/London /etc/localtime
Filename TAB completion will help you to find the right file.
Technically, the correct way is to create a symlink instead of duplicating the file:

Code: Select all

rm /etc/localtime
ln -s /usr/share/zoneinfo/Europe/London /etc/localtime

User avatar
DougieLawson
Posts: 30166
Joined: Sun Jun 16, 2013 11:19 pm
Location: Basingstoke, UK
Contact: Website

Re: Setting the Timezone

Wed Sep 07, 2016 8:12 am

Guess what sudo dpkg-reconfigure tzdata does for you for free without any effort? Isn't it easier to use a pretty program with a nice simple menu rather than mucking about with finding files and making symbolic links?
Microprocessor, Raspberry Pi & Arduino Hacker
Mainframe database troubleshooter
MQTT Evangelist
Twitter: @DougieLawson

Since 2012: 1B*5, 2B*2, B+, A+, Zero*2, 3B*3

Please post ALL technical questions on the forum. Do not send private messages.

sleepnbum
Posts: 2
Joined: Fri Sep 16, 2016 9:12 pm

Re: Setting the Timezone

Tue Sep 20, 2016 5:37 pm

I needed the ability to change the timezone programmatically because I use scripts to setup my Pi's. Thank you jojopi and jcoutch for your answers, it helped me with mine:

Code: Select all

sudo rm /etc/localtime
sudo ln -s /usr/share/zoneinfo/US/Pacific /etc/localtime
sudo rm /etc/timezone
echo "US/Pacific" | sudo tee /etc/timezone 
I added a change to /etc/timezone. I'm not sure how necessary it is...

Normang
Posts: 2
Joined: Sun Jun 26, 2016 3:16 pm
Location: Texas

Re: Setting the Timezone

Sun Sep 25, 2016 5:30 pm

CMontcalm wrote:
jojopi wrote:The correct way to set the system timezone is to clobber /etc/localtime. This should work across most distros.sudo cp /usr/share/zoneinfo/Europe/London /etc/localtime
Filename TAB completion will help you to find the right file.
I'm quite new to Linux and I wanted to say that this answer was very strait forward and worked perfectly.
Thank You
I tried this and the change did not survive a apt-get update, apt-get upgrade, reboot.
I used pckg-reconfigure tzdata and the results appear to hold. Perhaps someone could explain why.

jbpark03
Posts: 2
Joined: Wed Feb 08, 2017 7:30 am

Re: Setting the Timezone

Wed Feb 08, 2017 7:50 am

jojopi wrote:The correct way to set the system timezone is to clobber /etc/localtime.  This should work across most distros.sudo cp /usr/share/zoneinfo/Europe/London /etc/localtime
Filename TAB completion will help you to find the right file.
Yes, it works.
$ sudo cp /usr/share/zoneinfo/Asia/Seoul /etc/localtime
for Seoul / "South Korea"

mhmmx
Posts: 2
Joined: Mon Feb 13, 2017 4:39 pm

Re: Setting the Timezone

Tue Oct 17, 2017 1:28 pm

jojopi wrote:
The correct way to set the system timezone is to clobber /etc/localtime. This should work across most distros.sudo cp /usr/share/zoneinfo/Europe/London /etc/localtime
Filename TAB completion will help you to find the right file.
This works for me for most timezones, but for some reason when trying to use this method for the GMT zoneinfo files found in zoneinfo/Etc directory the time is off. For example using the GMT-4 zoneinfo file the correct date would be "Tue Oct 17 9:19:36 GMT-4 2017" but instead it produces "Tue Oct 17 17:19:36 GMT-4 2017" which is 10 hours off. Do you guys have any suggestions?

davidm77
Posts: 1
Joined: Mon Oct 23, 2017 2:22 pm

Re: Setting the Timezone

Mon Oct 23, 2017 2:26 pm

This is the Raspberry Pi. The standard, dead-simple way to do this 'sudo raspi-config'.

Return to “Beginners”

Who is online

Users browsing this forum: No registered users and 63 guests