The default time zone for Raspbian – which is the Linux distribution I installed on the Raspberry Pi – is UTC; this is not terribly convenient for somebody living in Illinois, so the other day I set about changing the Pi’s time zone to CST.
There are a great many ways to set the time zone in Linux. One is user-specific, the others are global but don’t always work on all platforms. Some work, but disappear after a while.
Run the tzselect utility. It will ask some questions, then spit out a line that looks like this:
TZ='America/Chicago'; export TZ
Add this line to
~/.profile and you’re done.
This only changes the time zone for the current user. (How many Raspberry Pi machines have multiple user accounts?) The system time zone remains UTC. And support-forum chatter suggests fooling with the TZ environment variable is deprecated.
The system time is controlled by
/etc/localtime. Overwrite it with the appropriate file from
sudo cp /usr/share/zoneinfo/America/Chicago /etc/localtime
On some distributions,
/etc/localtime is overwritten on system restart. Oops.
I’ve seen these proposed:
- (On Raspbian) run
sudo dpkg-reconfigure tzdata
I went with the
/etc/localtime method. It may not be the officially-blessed method – I’m not convinced that such a thing even exists – but it works.