The UNIX function mktime() is used to convert a date in struct tm format to a time_t value. However, mktime assumes that the date value is in the local time zone.

The easiest way to convert a UTC date is by setting the time zone environment variable first, as the following example code demonstrates:

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

void main(void)
{
	struct tm t;

	t.tm_mon = 0; // Jan
	t.tm_mday = 1;
	t.tm_hour = 0;
	t.tm_min = 0;
	t.tm_sec = 0;
	t.tm_year = 70;
	t.tm_wday = t.tm_yday = t.tm_isdst = 0;

	tzname[0] = tzname[1] = "GMT";
	timezone = 0;
	daylight = 0;

	setenv("TZ", "UTC", 1);

	printf("%d\n", mktime(&t));
	printf("tzname[0]=%s, tzname[1]=%s, timezone=%d, daylight=%d\n",
	tzname[0], tzname[1], timezone, daylight);
}