c - Reading system time as integers? -
this question has answer here:
- get current time in c 8 answers
i'm doing c programming course @ uni , 1 of tasks create opengl analogue clock on screen. want drive hour, minute, , second hands actual time.
how read hour, minute, , seconds system time? integers best. i've had around , can't find quite i'm after.
you should use localtime
, this:
#include <time.h> time_t timestamp = time(null); if (timestamp != (time_t)-1) { struct tm *t = localtime(×tamp); // use t->tm_hour, t->tm_min , t->tm_sec, ints }
see man 3 localtime
more info.
Comments
Post a Comment