473,387 Members | 1,597 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

days since 1 Jan 1970

Hello
How can i count how many there were days since 1 Jan 1970 ?

Thanx
Michal

Jul 19 '05 #1
6 14246
vertigo wrote:
How can i count how many there were days since 1 Jan 1970 ?


int time / 86400

--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
Jul 19 '05 #2
Gunnar Hjalmarsson wrote:
vertigo wrote:
How can i count how many there were days since 1 Jan 1970 ?

int time / 86400


Does that include compensation for leap seconds? =)
Purl Gurl
Jul 19 '05 #3
Purl Gurl wrote:
Gunnar Hjalmarsson wrote:
vertigo wrote:
How can i count how many there were days since 1 Jan 1970 ?


int time / 86400


Does that include compensation for leap seconds? =)


No, that would be an exercise for a time connoisseur.

--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
Jul 19 '05 #4
Gunnar Hjalmarsson wrote:
Purl Gurl wrote:
Gunnar Hjalmarsson wrote:
> > vertigo wrote: How can i count how many there were days since 1 Jan 1970 ? int time / 86400
Does that include compensation for leap seconds? =)
No, that would be an exercise for a time connoisseur.

Time connoisseur, typically boys who are almost always
a good day to a day and a half slower than us girls.

Since Jan 1, 1970, 34 years and 189 days.

One year equals 365.2425 days.

Current 365.242375 days per year, plus or minus a hemispherical .00031
seconds for our equator solar year. However, I am not a time connoisseur.
(34 * 365.2425) + 189 = 12607.245 days (plus or minus a second or two)

int time / 86400 = 12606

time / 86400 = 12606.8128240741
You boys are about a day behind us girls, plus or minus a wink or two.
Purl Gurl
Jul 19 '05 #5


On Wed, 07 Jul 2004 12:34:55 -0700, Purl Gurl wrote:

<SNIP>
int time / 86400 = 12606

time / 86400 = 12606.8128240741

You boys are about a day behind us girls, plus or minus a wink or two.


Actually, how would one know if a leap second [ 23 of them since 1970, as
per ftp://maia.usno.navy.mil/ser7/tai-utc.dat ] is missed on a system,
unless you have a way to compare its notion of "now" with some other
systems notion of "now".

At any rate, the "half-day" is more the result of your local timezone, for
time() returns the number of seconds in the epoch, which for most (but not
all) systems is midnight UTC on Jan 1, 1970 [ Dec 31, 1969 19:00
US/Eastern ]. So:

int time / 86400

will return the number of days (UTC) in the current epoch, which may or
may not be the number of days since Jan 1, 1970. Also, the number of days
will change at midnight UTC, which happens to be at 5am EST (4am EDT) for
where I am sitting. This may or may not be a problem for the originator of
this thread.

Take a look at the DateTime family of modules: its julian day functions
may give you what you need.
Jul 19 '05 #6
Purl Gurl wrote:
Since Jan 1, 1970, 34 years and 189 days.
You mean 188.5 days. It won't be 189 days until 23:59:59.9999999 GMT.
(Day-of-year starts at 1 instead of 0.)
(34 * 365.2425) + 189 = 12607.245 days (plus or minus a second or two)
Actually, it can be plus or minus an entire day, since leap day calculations
don't use fractional days.
time / 86400 = 12606.8128240741


Quite reasonable, since at the time that time() was evaluated, it was not
a full 189 days after Jan 1, 2004 00:00 GMT.

-Joe
Jul 19 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: Tom | last post by:
Please help. I need a quick little scrpit to place on a web page that will count how many days have passed since January 1, 1970. I have ZERO experience writing ANY scripts. Anyone have any...
4
by: Maziar Aflatoun | last post by:
Hi, Can someone please tell me how I can set DateTime to 01/01/1970 (UTC). Doing the following DateTime dt1 = new DateTime(1970, 1,1); Debug.WriteLine("dt1(utc):"+...
5
by: Simon Dean | last post by:
Probably being a little thick here, but when you subtract one date away from another, how do you convert the resultant value into a number of days... I guess I could easily / 60 / 60 / 24... but...
3
by: eight02645999 | last post by:
hi how can i get the number of days since epoch using the time module? or do i have to manually do the arithmetic? thanks
3
by: PyongHopscotch | last post by:
Hi all, I'm looking for a function that basically does localtime() or loacltime_s() but can handle dates before 1970. Does anyone know of some? -Pyong
2
by: Baron Samedi | last post by:
if I code $birth = strtotime('1 April 1950'); then $birth = -1, I guess that this is because time "began" on 1st Jan, 1970. (although I seem to remember a few good times before that). So,...
5
by: Beemer Biker | last post by:
I cant seem to get that date into any DateTime to make my calculation directly by subtracting "01-01-0000" from "now". After reading this:...
5
by: Grey Alien | last post by:
I need to convert timestamps that are given as the number of seconds that have elapsed since midnight UTC of January 1, 1970, (not counting leap seconds). It seems all of the std C functions...
5
by: Konstantinos Pachopoulos | last post by:
Hi, does any body now any such algorith? to find difference in days from YYYYMMDD to YYYYMMDD? Or just an algorithm, that converts YYYYMMDD to seconds since the epoch? Thanks
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.