Although QDateTime can obtain the millisecond time, but I don't know how to quickly break out the seven integer value (although you can pass the toString (... ) function to obtain the string, but it is not I need to quickly get seven integer value goal!)
CodePudding user response:
QDateTime can draw on the date and time () () to the QDate and QTimeQDate a year (), month (), day ()
QTime hour (), minute (), second (), msec ()
CodePudding user response:
CurrentDateTime getTime (){
//year - month - day (YYmmdd) : minutes: seconds (HHMMSS) milliseconds (MS) microseconds (USec) nanoseconds (NSec)
Time_t timep;
Time (& amp; Timep);
CurrentDateTime date;
Strftime (date) YMD_Str, sizeof (date. YMD_Str), "% % m - Y % d", a localtime (& amp; Timep));
Strftime (date) HMS_Str, sizeof (date. HMS_Str), "M H % : % : % S", a localtime (& amp; Timep));
//ms
Struct timeb TB;
Ftime (& amp; TB);
Sprintf (date. MS_Str, "% 3 d", TB. Millitm);
//ms
Struct timeval usectime;
//long usec=0;
The gettimeofday (& amp; Usectime, NULL);
//usec=usectime tv_sec * 1000000 + usectime tv_usec;
//printf (" ldus usectime: %, % ldus \ n ", usec, usectime. Tv_usec);//340483 us
Snprintf (date. USec_Str, 8, "% 6 ld," usectime. Tv_usec);
//nanosecond
//long nsec=0;
Struct timespec nsectime;
Clock_gettime (CLOCK_REALTIME, & amp; Nsectime);
//nsec.=nsectime tv_sec * 1000000000 + nsectime tv_nsec;
//printf (" LDNS nsectime: %, % LDNS \ n ", nsec, nsectime. Tv_nsec);//340487042 ns
Snprintf (date) NSec_Str, 14, "% 09 ld," nsectime. Tv_nsec);
return date;
}