Search notes:

libc: Date and time

#include <time.h>
time_t      time        (time_t *result);
double       difftime   (time_t time1, time_t time0);
struct tm * localtime   (const time_t *time);
struct tm * localtime_r (const time_t *time, struct tm *resultp);
struct tm * gmtime      (const time_t *time);
struct tm * gmtime_r    (const time_t *time, struct tm *resultp);
time_t      mktime      (struct tm *brokentime);
time_t      timelocal   (struct tm *brokentime);
time_t      timegm      (struct tm *brokentime);

char       *asctime     (const struct tm *brokentime); // --> "Mon Jun 10 20:19:18 2018\n" 
char       *asctime_r   (const struct tm *brokentime, char *buffer); // buffer should be 26 bytes long
char       *ctime       (const time_t *time);
char       *ctime_r     (const time_t *time, char *buffer);
size_t      strftime    (char *s, size t size, const char *template, const struct tm *brokentime);
size_t      wcsftime    (wchar_t *s, size t size, const wchar_t *template, const struct tm *brokentime)

struct tm * getdate     (const char *string);
int         getdate_r   (const char *string, struct tm *tp);
char      *strptime     (const char *s, const char *fmt, struct tm *tp);


int         stime (const time_t *newtime)

int         ntp_gettime (struct ntptimeval *tptr)

 

int         gettimeofday (struct timeval *tp, struct timezone *tzp);
int         settimeofday (const struct timeval *tp, const struct timezone *tzp);
int         adjtime (const struct timeval *delta, struct timeval *olddelta);
int         adjtimex (struct timex *timex);
Get CPU time:
#include <time.h.
clock_t start = clock();
do_stuff();
clock_t end   = clock();
double cpu_time_used = ((double) (end - start)) / CLOCKS_PER_SEC;

See also

struct tm
struct timeval
struct timespec
struct tms
struct timezone
The Standard C Library
time_t: Unix time

Index

Fatal error: Uncaught PDOException: SQLSTATE[HY000]: General error: 8 attempt to write a readonly database in /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php:78 Stack trace: #0 /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php(78): PDOStatement->execute(Array) #1 /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php(30): insert_webrequest_('/notes/developm...', 1758201475, '216.73.216.150', 'Mozilla/5.0 App...', NULL) #2 /home/httpd/vhosts/renenyffenegger.ch/httpsdocs/notes/development/languages/C-C-plus-plus/C/libc/date-and-time/index(95): insert_webrequest() #3 {main} thrown in /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php on line 78