How do I find the current system timezone?

后端 未结 12 477
攒了一身酷
攒了一身酷 2020-11-30 06:22

On Linux, I need to find the currently configured timezone as an Olson location. I want my (C or C++) code to be portable to as many Linux systems as possible.

For e

12条回答
  •  北荒
    北荒 (楼主)
    2020-11-30 07:21

    According to this page, it looks like if you #include it will declare the following.

    void tzset (void);
    extern char *tzname[2];
    extern long timezone;
    extern int daylight;
    

    Does that give you the information that you need?

提交回复
热议问题