how to get the system time in c language

how to get the system time in c language....

for this program

time_t t;
time(&t);
printf("%s",ctime(&t));

the output will be like this .... sun jan 24 20:34:58 2010 (example).

but how to get those character (sun,jan) and integers (24,20,34,58,2010)...to the user defined variables and print them seperately....

means if we declare variables like this ....

char a[3],b[3];
int date,hrs,mins,secs,year;

then the day,month,day,hrs etc must be stored in the respected variables....
and to print those variables where ever we want....

please give program for this......
1
2
3
4
5
6
7
8
9
10
11
12
13
/* time example */
#include <stdio.h>
#include <time.h>

int main ()
{
  time_t seconds;

  seconds = time (NULL);
  printf ("%ld hours since January 1, 1970", seconds/3600);
  
  return 0;
}

http://www.cplusplus.com/reference/clibrary/ctime/time/
why the seconds are calculating from 1970 jan 1..... please clear my doubt.....
thank you very much.....
Topic archived. No new replies allowed.