how do i get the time in seconds starting from 2000 to now

i need to get the time in seconds from jan 1 2000 up to today ,i cant seem to get it
thanks


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#include <iostream> 
/* time example */
#include <stdio.h>
#include <time.h>

int main ()
{
  time_t seconds;

  seconds = time (NULL);
  printf ("%ld hours since January 1, 1970 \n", seconds);
  printf ("%ld hours since January 1, 1970 \n", seconds/3600);
  printf ("%ld \n", seconds/3600-262800);




    // give the user a chance to look things over before quitting
  
  system("pause");

  return 0;
} 
So what's the problem? If you want seconds, then why are you messing around with hours?
There's more than 262800 hours between 1.1.1970 and 1.1.2000, by the way.
i must have it wrong ill recheck it
thanks
allright im coming up with 392240776 from 1,1,january 2000 to now
i got it i hope .
thanks all

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#include <iostream> 
/* time example */
#include <stdio.h>
#include <time.h>
using namespace std;


int main ()
{
  time_t seconds;

  seconds = time (NULL);
  printf ("%ld seconds since January 1, 2000 \n", seconds-946080000);
  

   cout << hex << seconds-946080000 << endl;


    // give the user a chance to look things over before quitting
  
  system("pause");

  return 0;
}
That's incorrect. See:
There are more than 262800 hours between 1.1.1970 and 1.1.2000, by the way.
i dont understand ,i figured the seconds per year times thirty years subtract that from total ,,right
You've heard of leap years, right?
How did you determine seconds per year? If you're older than 4, you should know it's not 365*24*60*60.
i did 24*60*60*365 and leap year ooh add a day every four?
Yes. You can just write that in code, makes it much more obvious what you're trying to do:
1
2
const int secondsBetween1970and2000=(365*30+7)*24*60*60;
... seconds-secondsBetween1970and2000);
Last edited on
The mean should be 365,24-somethingish days per year. Either use that, or count leap years.
Last edited on
ok i added 7.5 days both ways come out the same
thank yall
There are 7 leap years between 1970 and 2000, not 7.5.
Topic archived. No new replies allowed.