time_t - C time.h

C examples for time.h:time_t

Type

data type

From


<ctime>
<time.h>

Description

Time type

Demo Code


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

int main ()//from www .  j  ava 2  s  . co m
{
  time_t timer;
  struct tm year2020 = {0};
  double seconds;

  year2020.tm_hour = 0;   
  year2020.tm_min = 0; 
  year2020.tm_sec = 0;
  year2020.tm_year = 120; 
  year2020.tm_mon = 0; 
  year2020.tm_mday = 1;

  time(&timer);  /* get current time; same as: timer = time(NULL) */

  seconds = difftime(timer,mktime(&year2020));

  printf ("%.f seconds since January 1, 2000 in the current timezone", seconds);

  return 0;
}

Related Tutorials