Google Answers Logo
View Question
 
Q: Calculate number of elapsed days since Jan 01, 1970 ( Answered 3 out of 5 stars,   4 Comments )
Question  
Subject: Calculate number of elapsed days since Jan 01, 1970
Category: Miscellaneous
Asked by: javaboy11-ga
List Price: $2.00
Posted: 29 Oct 2002 16:52 PST
Expires: 28 Nov 2002 16:52 PST
Question ID: 92605
how do I calculate the number of days elapsed since January 1, 1970.
Also I would need to conceder Leap years.
Answer  
Subject: Re: Calculate number of elapsed days since Jan 01, 1970
Answered By: bobbie7-ga on 29 Oct 2002 17:26 PST
Rated:3 out of 5 stars
 
Hello Javaboy,


To calculate the number of days elapsed since January 1, 1970 until
today October 29, 2002  go  to the “How many days have you lived so
far” Website.
http://mcs.ltu.edu/xwang/ManyDays.htm

In the space provided for year, write 1970.
In the space provided for month, write 1.
In the space provided for day, write 1.

Now press “Submit”.

The number of days elapsed from January 1, 1970 are 11989.

According to the Gregorian calendar, which is the civil calendar in
use today, years evenly divisible by 4 are leap years, with the
exception of centurial years that are not evenly divisible by 400.
Therefore, the years 1700, 1800, 1900 and 2100 are not leap years, but
1600, 2000, and 2400 are leap years.
http://weather.wsmr.army.mil/leap.htm

Leap years from January 1, 1970 until today are:

1972
1976
1980
1984
1988
1992
1996
2000


Search criteria:

how many days have you lived
leap years

Thank you for your question and I hope this response has provided you
with the information you were seeking. If there is anything missing
from my answer, please post a request clarification before rating my
answer and I will do my best to meet your needs.


Best Regards,
Bobbie7-ga

Request for Answer Clarification by javaboy11-ga on 29 Oct 2002 17:56 PST
I need to know how to calculate number of days elapsed since Jan 01, 1970. 
preferable a date algorithm.

Clarification of Answer by bobbie7-ga on 29 Oct 2002 19:00 PST
Are you looking for an actual mathmatical formula or some type of program/applet?

Clarification of Answer by bobbie7-ga on 29 Oct 2002 19:41 PST
Algorithm for calculating time unit of change
 
To calculate time unit of change between two dates:
http://www.javaworld.com/javaworld/jw-03-2001/jw-0330-time-p3.html

Clarification of Answer by bobbie7-ga on 29 Oct 2002 20:03 PST
Hello again,

I  have been discussing your question with a fellow researcher.
 
This type of problem is very common in computer science exercises. One
common answer may be convert to Julian calendar and subtract.

Here's a thread from Usenet which address your inquiry:
http://groups.google.com/groups?hl=en&lr=&ie=UTF-8&oe=UTF-8&selm=hinnant-1609992035010001%40ith3-103.twcny.rr.com&rnum=10

General Date Algorithms Page 
http://home.capecod.net/~pbaum/date/date0.htm 

Page devoted to "Difference Between Dates" problem 
http://home.capecod.net/~pbaum/date/diff.htm 

I hope this helps.

--Bobbie7-ga

Request for Answer Clarification by javaboy11-ga on 30 Oct 2002 06:03 PST
I'm actual look for a mathmatical formula or some kind of java program
will do, but it can not use the date utililty in java.

Clarification of Answer by bobbie7-ga on 30 Oct 2002 06:30 PST
Hello Javaboy,

A mathematical formula with to calculate elapsed days may be found here:
http://www.math.ubc.ca/~cass/jd.pdf

I hope I got it right this time.

Thanks for your patience.

--Bobbie7-ga

Request for Answer Clarification by javaboy11-ga on 30 Oct 2002 07:38 PST
hi bobbie7,

The mathematical formula you found is great. Can you find a java code
that use the same mathematical formula start at an arbitrary point in
time – say January 1, 1970. Remember this code can not use the java
utililty.

Thanks for your being patience with me.

Clarification of Answer by bobbie7-ga on 30 Oct 2002 08:07 PST
Hi again,

Here is a script that may be what you need.

http://javascript.internet.com/calculators/age-calculator.html

I hope this works for you!

--Bobbie7-ga

Clarification of Answer by bobbie7-ga on 30 Oct 2002 08:35 PST
Perhaps these links can help.

http://groups.google.com/groups?q=java+code+julian+day&hl=en&lr=&ie=UTF-8&oe=UTF-8&selm=7dgole%2436c%241%40shell15.ba.best.com&rnum=4

http://groups.google.com/groups?q=java+code+julian+day&hl=en&lr=&ie=UTF-8&oe=UTF-8&selm=7cav9v%24fbo%241%40news.erinet.com&rnum=8

http://groups.google.com/groups?q=java++source+code+julian+day&hl=en&lr=&ie=UTF-8&oe=UTF-8&selm=7dgole%2436c%241%40shell15.ba.best.com&rnum=3

http://www.gaoassociates.com/untitled5.htm

http://groups.google.com/groups?q=source+code+julian+day&hl=en&lr=&ie=UTF-8&oe=UTF-8&selm=760972319snz%40dfdesign.demon.co.uk&rnum=3
javaboy11-ga rated this answer:3 out of 5 stars

Comments  
Subject: Re: Calculate number of elapsed days since Jan 01, 1970
From: rpcxdr-ga on 29 Oct 2002 17:40 PST
 
All computers have an internal clock that keeps time by measuring the
number of milliseconds that have passed since Jan 1st, 1970 - a day
coders call the "epoch."  Most programming languages have a built in
way to find this number.  In Java, you can answer your question with
the following program:

public class Dayz {
    public static void main(String[] args) {
        long days = System.currentTimeMillis()/1000/60/60/24;
        System.out.println("Days since the epoch: "+days);
    }
}

Why was Jan 1st, 1970 chosen for computers to measure time against? 
That will be another $2.00. =)
Subject: Re: Calculate number of elapsed days since Jan 01, 1970
From: rpcxdr-ga on 29 Oct 2002 17:56 PST
 
Right.  You are "javaboy," eh?  Then you already know this!  You asked
about leap years.  Leap years only have an effect after the
milliseconds are converted to the Gregorian calendar.  Even during the
skipped day, the milliseconds keep ticking forward as if nothing had
happened.  However what you should really be concerned about is the
gain of a second that occurs every few years.  After 32 years, the
clocks in all computers have drifted by a few seconds.  So for those
few seconds each day, your calculation - the one given in the program
above - will be one day off.  But you don't really want the
"scientific" number, do you?
Subject: Re: Calculate number of elapsed days since Jan 01, 1970
From: rpcxdr-ga on 29 Oct 2002 18:14 PST
 
You can target future Java questions better by posting to
Google Answers > Computers > Programming 
https://answers.google.com/answers/main?cmd=search&catid=1207
Subject: Re: Calculate number of elapsed days since Jan 01, 1970
From: iso8601-ga on 31 Oct 2002 16:44 PST
 
There are also now some agreed International Standards for Date and
Time, setting definitions for Seconds and all related units, defining
how leap years are calculated, as well as showing various formats for
specifying dates (such as 2002-10-31, 2002-W44-D4, or 2002-304, for
2002-Oct-31).

Search for ISO 8601, or get a quick overview from the Google
Directory:  http://directory.google.com/Top/Science/Reference/Standards/Individual_Standards/ISO_8601/
.

Important Disclaimer: Answers and comments provided on Google Answers are general information, and are not intended to substitute for informed professional medical, psychiatric, psychological, tax, legal, investment, accounting, or other professional advice. Google does not endorse, and expressly disclaims liability for any product, manufacturer, distributor, service or service provider mentioned or any opinion expressed in answers or comments. Please read carefully the Google Answers Terms of Service.

If you feel that you have found inappropriate content, please let us know by emailing us at answers-support@google.com with the question ID listed above. Thank you.
Search Google Answers for
Google Answers  


Google Home - Answers FAQ - Terms of Service - Privacy Policy