### Titanic Sinking Timer

i am making a timer that tells me how many seconds, minutes, hours, days and years ago the titanic sunk i am confused on where to start the calculation. It sank at 2:20 AM on April 10th 1912, i was thinking of doing liek a start and end time kind of like this old code i found, but how do i set the start time?

 ``12345`` ``````time_t endTime = time(0), playTime = endTime - startTime, hoursTime = playTime / 3600, minutesTime = (playTime / 60) % 60, secondsTime = playTime % 60;``````

 ``12345678910111213141516171819202122`` ``````#include #include using namespace std; int main() { time_t time_seconds; time_t time_minutes; time_t time_hours; time_t time_days; time_t time_years; time_t current = time(0); cout << "Current Time: " << ctime(¤t); cout << '\n'; cout << "The Titanic sank: " << time_seconds << " Seconds, " << time_minutes << " Minutes, " << time_hours << " Hours, " << time_days << " Days, " << " and " << time_years << " years ago" << endl; }``````
Last edited on
One way, certainly not the only way...

Epoch time is based on the number of seconds since 1/1/1970.

First determine the number of seconds since 2:20 AM on April 10th 1912 to 1/1/1970.

Then, each time you run the program, add the number of seconds since 2:20 AM on April 10th 1912 to the current Epoch time to get the number of seconds since the Titanic sank.

*edit* My count from 2:20 AM on April 10th 1912 to 1/1/1970 is 30362320 minutes.
21071 normal days in years
14 leap years
less
2 hours 20 mins

I didn't try too hard to confirm that so you might want to check math.

So my guess is the Titanic sunk roughly Titanic Sunk = 3200825128 seconds ago and counting....
Last edited on
Topic archived. No new replies allowed.