I have
int year, month, day, hour, min, sec
How can I get the epoch time in C++?
I am having difficulty figuring it out using Boost, any examples or alternative ways to do it?
I have
int year, month, day, hour, min, sec
How can I get the epoch time in C++?
I am having difficulty figuring it out using Boost, any examples or alternative ways to do it?
You're making it too complicated. Have a look at the time functions in the standard libraries.
Fill in a struct tm with your values, then call mktime().
I'm assuming by "get the epoch time" you mean the number of seconds since the epoch, i.e. Unix time_t.
This boost example should do what you ask for if I did understand your problem correctly.
#include <iostream>
#include <sys/time.h>
int main ()
{
unsigned long int seconds = time(NULL);
std::cout << seconds << std::endl;
return 0;
}