|
|
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. |
|
Subject:
Re: Calculate number of elapsed days since Jan 01, 1970
Answered By: bobbie7-ga on 29 Oct 2002 17:26 PST Rated: |
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 | |
| |
| |
| |
| |
| |
| |
| |
| |
|
javaboy11-ga rated this answer: |
|
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/ . |
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 Home - Answers FAQ - Terms of Service - Privacy Policy |