Thread: Set timezone in linux

  1. #1
    Registered User
    Join Date
    Aug 2010
    Posts
    2

    Set timezone in linux

    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!
    Last edited by iman453; 08-04-2010 at 12:45 PM. Reason: wording

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,656
    > Is there any function I can use to set the timezone of the entire system in linux using C?
    Have you ever seen timestamps screwed up by daylight savings time corrections?

    There is settimeofday(), but you need to be root to call it.
    settimeofday(2): get/set time - Linux man page

    You might want to consider whether your local convenience is at the expense of a system wide headache.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  3. #3
    Registered User
    Join Date
    Aug 2010
    Posts
    2
    Basically, I just started interning at this company that makes video conferencing devices. And I need to write a function which sets the time zone of the device, based on this struct that is passed to the function (the struct contains the timezone), so that the device can display the time in local time I guess.

    It says on the site that 'The use of the timezone structure is obsolete', and so I was wondering if there is any other function that does that.

    Thanks for your help, I appreciate it.

  4. #4
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,656
    Scroll to the bottom, and click through the "see also" links.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. linux, doubles, and unions
    By paraglidersd in forum Linux Programming
    Replies: 14
    Last Post: 11-19-2008, 11:41 AM
  2. Replies: 8
    Last Post: 03-10-2008, 12:08 PM
  3. "if you love someone" :D
    By Carlos in forum A Brief History of Cprogramming.com
    Replies: 12
    Last Post: 10-02-2003, 01:10 AM
  4. Set Classes
    By Nicknameguy in forum C++ Programming
    Replies: 13
    Last Post: 10-31-2002, 02:56 PM