Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > days since 1 Jan 1970

Reply
Thread Tools

days since 1 Jan 1970

 
 
vertigo
Guest
Posts: n/a
 
      07-07-2004
Hello
How can i count how many there were days since 1 Jan 1970 ?

Thanx
Michal

 
Reply With Quote
 
 
 
 
Gunnar Hjalmarsson
Guest
Posts: n/a
 
      07-07-2004
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
 
Reply With Quote
 
 
 
 
Purl Gurl
Guest
Posts: n/a
 
      07-07-2004
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
 
Reply With Quote
 
Gunnar Hjalmarsson
Guest
Posts: n/a
 
      07-07-2004
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
 
Reply With Quote
 
Purl Gurl
Guest
Posts: n/a
 
      07-07-2004
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
 
Reply With Quote
 
Derek Ludwig
Guest
Posts: n/a
 
      07-08-2004


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.
 
Reply With Quote
 
Joe Smith
Guest
Posts: n/a
 
      07-08-2004
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
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Obtaining number of seconds since Jan 1 1970. JC C++ 4 01-07-2009 09:27 PM
Unix time (predating epoch of Jan-1970) Grey Alien C Programming 5 07-20-2007 12:21 AM
covert time from date Hour min sec format to epoch time i.e time since 1 jan 1970 in C Summu82 C Programming 5 06-07-2006 02:51 PM
Rookie Question: Need a Script To Count How Many Days Have Passed Since January 1, 1970 Tom Javascript 7 06-18-2004 12:31 PM
A simple example calculating the number of seconds since 01/01/1970 cyril C Programming 4 08-25-2003 08:25 AM



Advertisments