well lets do the math.
1 minute = 60 seconds.
60 minutes = 1 hr = 60 * 60 = 3600 Seconds in 1 hour.
24 hr = 1 day = 3600 * 24 = 86400 seconds in 1 day. There are
365.25 Days in a year = 86400 * 365.25 = 31557600 Seconds in a year.
so from 2013 - 1970 that is 43 yrs which is 31557600 * 43 = 1356976800 Seconds. A unsigned long long has a max value of: 18446744073709551615
so the maximum difference would be 18446744073709551615 / 31557600
= 584542046090.62639791999391588714 years. So unless you are trying to find the number of seconds that passed form now until the creation of everything you may need to use long doubles or even possibly large =p
To get your result you will have to work backwards. Or figure the amount of seconds from each one then subtract them from each other.
Oh I see http://www.cplusplus.com/reference/ctime/tm/ sorry I haven't used that before. Have only used one of the time function so far (for getting a random seed.) I'm still fairly new (4-5months.)
#include <iostream>
/* mktime example: weekday calculator */
#include <ctime> /* time_t, struct tm, time, mktime */
int main()
{
// time: 16 00 26
// date: 11 02 13
std::tm time2013;
time2013.tm_hour = 16;
time2013.tm_min = 00;
time2013.tm_sec = 26 ;
time2013.tm_mday = 11;
time2013.tm_mon = 2-1;
time2013.tm_year = 113;
// The Microsoft library internally uses Universal Coordinated Time (UTC)
// Your time zone setting may be such that midnight 1 Jan 1970 local time
// is a timepoint before midnight 1 Jan 1970 UTC.
// std::time_t of zero specifies start of epoh (midnight 1 Jan 1970 UTC)
std::cout << std::fixed << std::difftime( std::mktime(&time2013), 0 ) << '\n' ;
}
The library can't handle time points before the start of the epoch.
Run this program on your machine to see what is the start of epoch.
1 2 3 4 5 6 7 8 9
#include <iostream>
#include <ctime>
int main()
{
std::time_t the_beginning_of_time {} ;
std::cout << "earliest timepoint that can be handled by the library is:\n"
<< std::ctime( &the_beginning_of_time ) ;
}