如何使用C ++获取Linux机器时区 [英] How to get Linux machine time zone using C++

查看:92
本文介绍了如何使用C ++获取Linux机器时区的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我是C ++的新手,我在C ++中有一个服务器应用程序,我想用C ++获取Linux机器时区。我能够在Windows机器中获得时区我希望区域ID在我的客户端应用程序中执行某些功能。我尝试了很多搜索没用。任何人都可以帮助我摆脱它。在此先感谢。

Hi All,
I am new to C++, I have a server application in C++ in that i want to get the Linux machine time zone using C++. I am able to get the time zone in windows machine i want to zone id to do some functionality in my client application. I tried lot search not useful. Can any one help me to come out of it. Thanks in advance.

推荐答案

也许这会有所帮助:

如何在Linux上用C ++获取当前时区 [ ^ ]

也许吧。 ..
Maybe this helps:
How to get current timezone on linux in C++[^]
maybe...


#include <ctime>
#include <iostream>

int main(void)
{
    time_t rawtime;
    struct tm * ptm;
    time ( &rawtime );
    ptm = gmtime ( &rawtime );

    //const char *tm_zone; /*Timezone abbreviation*/
    std::cout << ptm->tm_zone;
    //output: "GMT" in my machine.

    return 0;
}





我的linux盒子:

---------- ---

Linux jcasimiro-Mint 3.11.0-12-generic#19-Ubuntu SMP Wed 10月9日16:20:46 UTC 2013 x86_64 x86_64 x86_64 GNU / Linux



JAFC



My linux box:
-------------
Linux jcasimiro-Mint 3.11.0-12-generic #19-Ubuntu SMP Wed Oct 9 16:20:46 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux

JAFC


这篇关于如何使用C ++获取Linux机器时区的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆