Convert date to time_t

Hi all,

I am writing a C++ program which takes date & time input from the user. This is then parsed into a struct such as:

1
2
3
4
5
6
7
8
struct time
{
  short year;
  short month;
  short day;
  short hour;
  short min;
};


My question is: how can I convert such a struct into a time_t object, which is an unsigned long giving the time as the number of seconds elapsed since the epoch Jan 1st 1970, 00:00, as set out in time.h.

I am wondering if this can be achieved using the standard library, or whether I just need to write a function to perform the appropriate arithmetic.

Thanks guys :)

Shinkansen
That's terrific, thanks :)
Topic archived. No new replies allowed.