Linux application development-time programming

Source: Internet
Author: User

Linux Application Development-time programming

Time Type


World Standard Time: GMT


Calendar time: Number of seconds since 1970-1-1


Two time functions


1 Get Calendar Time


Name of function


Time


Function prototype


time_t time (time_t *t)


function function


Time from January 1, 1970, units in seconds


Owning header file


#include <time.h>


return value


The second speed of the successful return time


Failed return-1




Parameter description


Save return value












2 getting GMT


Name of function


Gmtime




Function prototype


struct TM *gmtime (const time_t *TIMEP)




function function


Convert calendar time to world standard Time


Owning header file


#include <time.h>


return value


Successful return time


Failed return-1


Parameter description


TIMEP is the address of the calendar time












3 Get local time


Name of function


LocalTime


Function prototype


struct TM *localtime (const time_t *TIMEP)


function function


Convert calendar time to local time


Owning header file


#include <time.h>


return value


Successful return to local time


Failed return-1


Parameter description


TIMEP is the address of the calendar time













4 Displaying the time in string mode


Name of function


Asctime


Function prototype


Char *asctime (const struct TM *tm)


function function


The time that the standard time is converted to a string display


Owning header file


#include <time.h>


return value


Successful return string pointer holds the string time


Failed return-1




Parameter description


parameter is a struct-body pointer of standard Time












5 Get High precision time


Name of function


Gettimeeofday


Function prototype


int gettimeofday (struct timeval *tv, struct timezone *tz);


function function


Get high-precision time


Owning header file


#inlclude <sys/time.h>


return value


Successful return 0


Failed return-1


Parameter description


TV saved from 1970-1-1-0 to now experience the number of seconds and microseconds


Tzone is usually null

Linux application development-time programming

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.