Time since the epoch (Just need quick help on math)

Hi all,
First and foremost, I want to say that I am NOT asking that one of you guys finish my homework, but I need a second opinion on this program that is trying to find the time since the epoch for me.
I know my math is all screwy on this one,
could someone please point out where might need to change something?

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#include <iostream>
#include <stdio.h>
#include <time.h>
using namespace std;

int main (){
    int dummy;
    int dummy2 = 0;
    time_t seconds;
    int minutes, hours, days, months, years;
    
    seconds = time (NULL);
    
    minutes = 60 * seconds;
   	dummy2 = dummy2 + double(60 / seconds);
    
    hours = 60 * minutes;
    dummy2 = dummy2 + double(60 / hours);
    
    days = 24 * hours;
    dummy2 = dummy2 + double(24 / hours);
    
    months = 30 * days;
    dummy2 = dummy2 + double(30 / days);
    
    years = 12 * months;
    dummy2 = dummy2 + double(12 / months);
    
    cout << "It has been " << endl
		 << "Years: " << years << endl
		 << "Months : " << months << endl
		 << "Days: " << days << endl
		 << "Hours: " << hours << endl
		 << "Minutes: " << minutes << endl
		 << "Seconds: " << seconds << endl
		 << "Since the epoch" << endl;
  
  cin >> dummy;
  return 0;
}


This is how I know im messing up,
This is my output:

1
2
3
4
5
6
7
8
9
10
/******************************************************************************
It has been
Years: -127172608
Months : -1800167424
Days: 1228484608
Hours: 2019713536
Minutes: 2109562752
Seconds: 1323649568
Since the epoch
*******************************************************************************/


Thanks in advance
Last edited on
You're multiplying instead of dividing at each step.
Topic archived. No new replies allowed.