time : time « time.h « C Tutorial






ItemValue
Header filetime.h
Declarationtime_t time(time_t *time);
Returnreturns the current calendar time of the system or -1 if the system has no time.


The time() function can be called either with a null pointer or with a pointer to a variable of type time_t.

If the latter is used, the variable will also be assigned the calendar time.

#include <time.h>
  #include <stdio.h>

  int main(void)
  {
    struct tm *ptr;
    time_t lt;
    lt = time(NULL);
    ptr = localtime(&lt);
    printf(asctime(ptr));

    return 0;
  }
Sat Mar  3 16:12:48 2007








25.12.time
25.12.1.time