Linux系统是怎么辨别gmtime和localtime
来源:才华咖 本文已影响4.61K人
来源:才华咖 本文已影响4.61K人
gmtime和localtime是两种不同的函数,不少人在使用的时候容易将两者混淆,下面小编就教你Linux下如何辨别gmtime和localtime的使用,以便你下次能够正确使用。
区别:
#include 《time.h》
#include 《stdio.h》
int main(int argc, char **argv)
{
time_t tmpcal_ptr = {0};
struct tm *tmp_ptr = NULL;
tmpcal_ptr = time(NULL);
printf(“tmpcal_ptr=%d”, tmpcal_ptr);
tmp_ptr = gmtime(&tmpcal_ptr);
printf(“after gmtime, the time is:%d:%d:%d”, tmp_ptr-》tm_hour, tmp_ptr-》tm_min, tmp_ptr-》tm_sec);
tmp_ptr = localtime(&tmpcal_ptr);
printf(“after localtime, the time is:%d:%d:%d”, tmp_ptr-》tm_hour, tmp_ptr-》tm_min, tmp_ptr-》tm_sec);
return 0;
}
运行结果如下:
基本的意思是,gmtime转出来的是0时区的标准时间
localtime是将时区考虑在内了,转出的当前时区的时间。但是注意,有些嵌入式设备上被裁减过的.系统,时区没有被设置好,导致二者转出来的时间都是0时区的。
上面就是Linux区别gmtime和localtime函数的相关介绍了,从上面的代码运行结果中可以看出,gmtime和localtime的用法是有些区别的。
托福英语写作范文:Examinations exert a pernicious influence on educat
The First Time to Make Dumplings英语作文及译文
Module 3 Unit 2 I dont like riding my bike说课稿范文
英语初级口语: Meddling Mother-In-Law Comment
英国留学传媒硕士Media/Journalism/Communication解析
win7系统重装win10提示not a valid image file
2016商务英语写作范文:Emotional Intelligence
PetaLinux操作系统在MicroBlaze系统中的移植解析
英语阅读:African Union Leaders Talk Mali, Chinese Investmen
英语作文:Time Is More Valuable Than Money
七下Module 10 Unit 2 This morning we took a walk评课稿
How I Finance My College Education英语作文
The Sprint in College Entrance Exam英语作文
Unit 5 It must belong to Caral section A英语评课稿
Module 7 Travel Unit 2 We are going to visit the Ming Tombs
Modern Technology Makes Life More Conv英语六级作文
i still remember that halloween英语作文
Margaret Sanger: The Morality of Birth Control quo
如何辨别一家公司是不是好公司
《Module 4 Unit 2 Does Daming like bananas?》说课稿
辨别的近义词是什么
Linux系统下的ipmitool工具应该怎样使用
Go Tell It to the Mountain英语美文
The Limitation of The Violence Shot 暴力镜头的限制英语作文
The Impact of Information Explosion高中英语作文
The place of Science and Technology in Modern Life英语作文
最新《Fate/Stay Night Unlimited Blade Works》经典名句
Linux操作系统版本要怎么查看
Linux Mint Cinnamon下使用vino-server配置桌面共享的方法
Unit2 My schoolbag A Let’s learn教学反思
英语阅读:VIT declines to acquire Ang Mo Kio property
Climbing in the Himalayas英语六级作文
离职怎么和大家道别
UN Chief Urges Leaders to Deliver on Climate Change美文欣赏
I Climbed Mount Tai初中英语作文
奥运英语作文:中国跳水队(Diving into Gold: Chinas Dream Team
高二英语Unit 3TheMillionPoundBankNote教案
The mountains the most beautiful female teachers英语作文
Module 4 Unit1 We’re going to tell stories.教学设计
Linux系统中smbclient命令的使用方法