当前位置:网站首页>12. Gettimeofday() and time()
12. Gettimeofday() and time()
2022-07-04 01:59:00 【666QAQ】
- gettimeofday()
gettimeofday()
Can be found intv
The buffer pointed to is returned from Epoch(UTC 1970.1.1 00:00:00) Seconds since , Date stored intime_t
Variable of type , This is a SUSv3 Defined integer type )
#include <sys/time.h>
int gettimeofday(struct timeval *tv, struct timezone*tz);
Returns 0 on success, or -1 on error
Parameters tv Is a pointer to the following data structure :
struct timeval{
time_t tv_sec; /*Seconds since 00:00:00, 1 Jan 1970 UTC*/
suseconds_t tv_sec; /*Addtional microseconds (long int)*/
}
Parameters tz Has been abandoned , Pass in on use NULL that will do .
2.time()time()
The function also returns from Epoch Seconds since , This is due to historical reasons ,gettimeofday()
More accurate , later time()
It is right gettimeofday()
Call to .
#include <time.h>
time_t time(time_t *timep);
Returns number of seconds since the Epoch or (time_t)-1 on error
time()
Return the number of seconds in two ways , Parameters timep Or return value , But to avoid mistakes , Usually simply call :
time_t t = time(NULL);
Reference material :《Linuc/UNIX System programming manual 》
边栏推荐
- Some other configurations on Huawei's spanning tree
- How to view the computing power of GPU?
- Jerry's watch information type table [chapter]
- What is the student party's Bluetooth headset recommendation? Student party easy to use Bluetooth headset recommended
- Openbionics robot project introduction | bciduino community finishing
- Gnupg website
- On Valentine's day, I code a programmer's exclusive Bing Dwen Dwen (including the source code for free)
- Iclr2022 | ontoprotein: protein pre training integrated with gene ontology knowledge
- Install the pit that the electron has stepped on
- Push technology practice | master these two tuning skills to speed up tidb performance a thousand times!
猜你喜欢
Openbionics robot project introduction | bciduino community finishing
Three layer switching ①
Applet graduation project based on wechat selection voting applet graduation project opening report function reference
IPv6 experiment
The automatic control system of pump station has powerful functions and diverse application scenarios
Introduction to superresolution
Feign implements dynamic URL
The boss said: whoever wants to use double to define the amount of goods, just pack up and go
On Valentine's day, I code a programmer's exclusive Bing Dwen Dwen (including the source code for free)
Jerry's synchronous weather information to equipment [chapter]
随机推荐
The reasons why QT fails to connect to the database and common solutions
How to view the computing power of GPU?
Bacteriostatic circle scanning correction template
High level application of SQL statements in MySQL database (I)
Openbionics exoskeleton project introduction | bciduino community finishing
Feign implements dynamic URL
Chapter 3.4: starrocks data import - Flink connector and CDC second level data synchronization
Example 073 square sum value judgment programming requires the input of a and B, if a ²+ b ² If the result of is greater than 100, a is output ²+ b ² Value, otherwise output the result of a + B.
TP5 automatic registration hook mechanism hook extension, with a complete case
String & memory function (detailed explanation)
A fan summed up so many interview questions for you. There is always one you need!
I don't know why it can't run in the project and how to change it
C import Xls data method summary II (save the uploaded file to the DataTable instance object)
Final consistency of MESI cache in CPU -- why does CPU need cache
How to subcontract uniapp and applet, detailed steps (illustration) # yyds dry goods inventory #
Notice on Soliciting Opinions on the draft of information security technology mobile Internet application (APP) life cycle security management guide
Learn these super practical Google browser skills, girls casually flirt
The contact data on Jerry's management device supports reading and updating operations [articles]
Mobile phone battery - current market situation and future development trend
Introduction to Tianchi news recommendation: 4 Characteristic Engineering