Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

there has been a few questions about this topic and i know the answer this could help others and maybe someone could help me out if what i want to do is possible

i want to chainge the timezone of the system clock from the terminal this caan be done with

tzselect "which opens a gui in terminal" or sudo cp /usr/share/zoneinfo/Europe/London /etc/localtime "which will set to gmt"

but is there a way to set time zone with just the offset ie.-1 or +5 etc?

i need to do this as im writing an aplication to adjust timeoffset or report logs and the only info i have is the user ip which i can use a webapp to locates location of ip but then i need to set offset which would be easy IF i could just get offset of location but if i need to find zone and city it would be a rreal pain if anyone knows the answer to how to set system clock with +/-hour would be great its hard to find info with ubuntu forums being down

share|improve this question
add comment

3 Answers

To change time zone from terminal, just press Ctrl+Alt+T on your keyboard to open Terminal. When it opens, run the command(s) below:

sudo dpkg-reconfigure tzdata

Once open, just follow the screens to change the time zone.

share|improve this answer
1  
This is the easiest, most painless method. –  Thomas W. Jul 22 '13 at 22:19
    
this wont work as i need to altr timezone from a program without user input i need a command i can feed into terminal not gui solution thanks for reply –  user2155009 Jul 23 '13 at 11:45
    
Exactly what I was looking for. +1 –  Doc Mar 7 at 5:20
add comment

You can use the GMT±x files in /usr/share/zoneinfo/Etc.

sudo ln -s /usr/share/zoneinfo/Etc/GMT$offset /etc/localtime
share|improve this answer
    
thanks allot for reply im getting an error ln: failed to create symbolic link `/etc/localtime': File exists oboiusly im not sure what im doing do you know of good tutorial for this or even some key words i can google thanks am i using command correctly? im using sudo ln /usr/share/zoneinfo/Etc/GMT$+1 /etc/localtime to set clock to +1gmt –  user2155009 Jul 22 '13 at 21:18
    
minitech forgot the force flag I guess so -> sudo ln -sf .... –  Tele Oct 28 '13 at 17:11
add comment

To change timezone on Linux server or workstation, You can copy timezone from /user/share/zoneinfo/ to /etc/localtime

for example

# cp /usr/share/zoneinfo/America/Toronto /etc/localtime
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.