473,729 Members | 2,164 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 14288
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
4669
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
6248
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
3250
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 etc between two dates... Just thought I'd run this
3
19047
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
3109
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
2992
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 for leap years?)
5
13668
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 starts at jan 1, 0000 private string DT2Matlab(DateTime thisDT)
5
8521
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 remarkable lack of foresight - and is *just* a little bit annoying. Does anyone know of an algo I can...
5
6402
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
8766
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 synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9291
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9218
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
6722
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 instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6026
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 into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4536
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 the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3244
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
2
2699
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2171
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 effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.