9th Lesson-Time Programming

Source: Internet
Author: User

1. GMT (UTC): World Standard Time. is based on the time standard of a place in London, England.
Calendar time: Starting at a standard point in time (1970.01.01.00:00:00:) and the number of seconds that are now experienced.
2. Function Learning
1.1 Get Calendar Time
Name of 1.1.1 function
Time
1.1.2 Function prototype
time_t time (time_t *t);
1.1.3 Function function
Return Calendar Time
1.1.4 Owning header file
<time.h>
1.1.5 return value
Success: Return from 1970.1.1.0:0:0: to current calendar time (in seconds)
Failure:-1, the corresponding error causes will be set in the global variable errno
1.1.6 parameter Description
T: Save return value if not null
1.2 Getting GMT
Name of 1.2.1 function
Gmtime
1.2.2 Function prototype
struct TM *gmtime (const time_t *TIMEP);
1.2.3 Function function
Convert calendar time to world standard Time
1.2.4 Owning header file
<time.h>
1.2.5 return value
Success: Returns the world standard Time, returned in the struct TM format.
Failure: NULL
1.2.6 parameter Description
TIMEP: The calendar time to convert.
1.3 Get local time
Name of 1.3.1 function
Loclatime
1.3.2 Function prototype
struct TM *localtime (const time_t *TIMEP);
1.3.3 function function
Converts the calendar time to local time and stores it in the TM structure.
1.3.4 Owning header file
<time.h>
1.3.5 return value
Success: Returns the local time, returned in the struct TM format.
Failure: NULL
1.3.6 parameter Description
TIMEP: Point to the calendar time you want to convert.
1.4 Displaying the time in string mode
Name of 1.4.1 function
Asctime
1.4.2 Function prototype
Char *asctime (const struct TM *TM);
1.4.3 function function
Converts the time of the struct TM format to a 26-byte string format
1.4.4 Owning header file
<time.h>
1.4.5 return value
Display time in string mode
1.4.6 parameter Description
TM: TM format time to convert
1.4.7 char* ctime (const time_t* TIMEP)
Convert calendar time directly to string time
1.5 Get high precision time
Can be used to measure the run time of a program
Name of 1.5.1 function
Gettimeofday
1.5.2 function prototype
int gettimeofday (struct timeval *tv, struct timezone *tz);
1.5.3 function function
Get high-precision time
1.5.4 Owning header file
<sys/time.h>
1.5.5 return value
Success: 0
Failed:-1
1.5.6 parameter Description
Tv: Contains the number of seconds and microseconds of the calendar time
Tz: usually null
1.5.7 UINT sleep (uint seconds);
How many seconds the program sleeps
1.5.8 void Usleep (ulong usec);
Subtle levels of hibernation

9th Lesson-Time Programming

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.