# Set timezone in linux



## iman453 (Aug 4, 2010)

Hi,

Is there any function I can use to set the timezone of the entire system in linux using C? (Other than creating a symbolic link between /etc/localtime and /usr/share/zoneinfo/). Could I specify the timezone offset in seconds by any chance?

Thanks in advance!


----------



## Squashman (Apr 4, 2003)

Please try and refrain from double posting. If you need a thread moved to another category you can report your thread to be moved.
http://forums.techguy.org/software-development/940684-set-timezone-linux.html


----------



## iman453 (Aug 4, 2010)

I'll make sure I report it next time around. Thanks.


----------



## lotuseclat79 (Sep 12, 2003)

Hi iman453,

Here is how to set the timezone in Linux for EDT (using the root/admin account):

```
# setup local timezone
rm /etc/localtime
# setup for EDT and EST (+4 EDT; +5 EST)
ln -s /usr/share/zoneinfo/EST5EDT /etc/localtime
# setup for only EST (+5 EST)
#ln -s /usr/share/zoneinfo/EST /etc/localtime
rm /etc/timezone
echo "US/Eastern" > /etc/timezone
export TZ="/usr/share/zoneinfo/America/New_York"
#Note: set system clock after this script runs with date -u MMDDhhmm
# where -u indicates the UTC time (4 hours ahead in EDT) or
# run an NTP time server to automate correct time
```
Read the man page for the date command, i.e. $ man date
or issue the command: $ date --help

-- Tom


----------

