gmtime and localtime are two different functions. Many people are confused when using them. The following small series teaches you how to distinguish between gmtime and localtime under Linux, so that you can use it correctly next time.
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=%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 (&afterquo;after localtime, the time is:\ %d:%d:%d”, tmp_ptr-"tm_hour, tmp_ptr-"tm_min, tmp_ptr-"tm_sec);
return 0;
}
results are as follows:
means that the basic, gmtime transferred out of the standard time zone 0:00
localtime is considered in the time zone Inside, the time of the current time zone that was transferred out. However, note that in some systems with embedded devices, the time zone is not set, and the time for both of them is 0 time zone.
The above is a description of the difference between gmtime and localtime functions in Linux. As can be seen from the above code running results, the usage of gmtime and localtime is somewhat different.
GitLab is an open source project for warehouse management systems. It is usually in
under Linux Git is an open source distributed version control system that can help Linux manage ker
Linux users often use the scp and sftp commands when transferring remote files. How
In the Linux system compiled link error, prompt undefined reference & rsquo; dlclose@xxx function er
The role of the Linux system pwd command
How to view the version of MariaDB server on Linux system
When prompted to start the vi editor in Linux, prompt E325: What should ATTENTION do?
What should I do if the Linux system time zone is wrong?
Linux using virtual machine to install Windows 10
How to modify the SSH port number in Linux?
How does CentOS VPS open port 80
Linux system prompts can not get the lock /var/lib/dpkg/lock how to do?
Linux system hard disk failure repair method
How Linux uses shell commands to detect PHP Trojans
The basic process of setting serial port properties in Linux system
How to uninstall Windows 7 wireless network card device driver
Win7 system suspended animation lost response skills
Ie can't set a blank page, what can I do if I can't use a blank page?
LOL Jay Chou live video super clear version Jay Chou LOL live video video
Let win8 be more user-friendly seven settings
Win10 Mobile annual update 14332 phone dialing flashback solution
Microsoft promotes Win8 next position
A few tricks let you say goodbye to the speed of the turtle system running Win7 system