473,569 Members | 2,458 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 14266
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.812824074 1
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.812824074 1

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.999999 9 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.812824074 1


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
4653
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 suggestions? As for what is displayed on the screen, I just want it to say: Today is: 12578 (or however many days have passed since that date.)
4
6232
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):"+ dt1.ToUniversalTime().ToString()); Doing the following returns 1/1/1970 5:00:00 AM
5
3243
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 that seems barbaric... Anything neater? Cheers Simon Ps, Im also just trying to work out how to calculate the number of mondays and tuesdays...
3
18892
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
3094
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
2985
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, what's the easiest way to find out how many days old I am (exactly, please, not just taking 1 April 1970 and adding 20 *365, which does not account...
5
13646
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: http://www.mathworks.com/matlabcentral/fileexchange/loadFile.do?objectId=11469&objectType=File I kluged up this routine that works: // convert date time into that funny matlab serial date time that...
5
8498
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 expect positive offsets from this date and are incapable of working on dates preceeding the epoch (i.e. negative offsets) - which IMHO shows a...
5
6388
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
7703
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7618
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
6287
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5514
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5223
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3657
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
1
2117
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1228
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
946
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.