c - Reading system time as integers? -


this question has answer here:

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(&timestamp);     // use t->tm_hour, t->tm_min , t->tm_sec, ints } 

see man 3 localtime more info.


Comments

Popular posts from this blog

angular - Ionic slides - dynamically add slides before and after -

minify - Minimizing css files -

Add a dynamic header in angular 2 http provider -