Hot search terms: 360 Security Guard Office365 360 browser WPS Office iQiyi Huawei Cloud Market Tencent Cloud Store
The following is an introduction to the difference between gmtime and localtime functions in Linux. As can be seen from the following code running results, there are some differences in the usage of gmtime and localtime. gmtime and localtime are two different functions, and many people tend to confuse the two when using them. The following editor will teach you how to distinguish the use of gmtime and localtime under Linux, so that you can use them correctly next time.
the difference:
#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=%dn", tmpcal_ptr);
tmp_ptr = gmtime(&tmpcal_ptr);
printf ("after gmtime, the time is: n%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: n%d:%d:%d", tmp_ptr-》tm_hour, tmp_ptr-》tm_min, tmp_ptr-》tm_sec);
return 0;
}
The running results are as follows:
The basic meaning is that what gmtime converts is the standard time in the 0 time zone
localtime is the time in the current time zone that is transferred out, taking the time zone into account. However, please note that on some systems that have been cut down on embedded devices, the time zone has not been set properly, causing the time transferred out by both to be in time zone 0.
Where is the QQ Music music account? How to check the QQ Music music account
How to turn off music pets in QQ Music How to turn off music pets in QQ Music
How to enable music pets in QQ Music Tutorial on how to enable music pets in QQ Music
How to check the music index in QQ Music Tutorial on how to check the music index in QQ Music
Where is QQ Music Music Community? How to view QQ Music Music Community
What to do if there is no sound after reinstalling the computer system - Driver Wizard Tutorial
How to practice typing with Kingsoft Typing Guide - How to practice typing with Kingsoft Typing Guide
How to upgrade the bootcamp driver? How to upgrade the bootcamp driver
How to change QQ music skin? -QQ music skin change method
Driver President Download-How to solve the problem when downloading driver software is very slow