You are here: Re: Number of days in 1/1/2000 « PHP Programming Language « IT news, forums, messages
Re: Number of days in 1/1/2000

Posted by Erwin Moller on 11/11/05 18:34

el_roachmeister@yahoo.com wrote:

> I am looking for a script that can report the number of days since
> 2000. It should handle leap years but I am not worried about accuracy
> to the hour/minute or seconds. I am writing a calendar program and need
> a reference point to base all my dates from. So I picked 1/1/2000.

Hi,

I think the most simple way is using Unix timestamps

(from http://nl2.php.net/manual/en/function.time.php)

*******************************
time() -> Return current Unix timestamp
Returns the current time measured in the number of seconds since the Unix
Epoch (January 1 1970 00:00:00 GMT).
*******************************

So code something like this:
1) Get the Unixtime for 1/1/2000 (you can calculate that only one time, and
use the number from then on hardcoded if you want)

2) Get the Unixtime for now: use the function time()

3) get the difference

4) divide it by the number of seconds in a day.

You will always get a 'dayfraction' this way, and have to do some rounding.

How you do the rounding is up to your taste of course.
(Eg, if the difference between now and 1/1/2000 is X and a half day, do you
want to work with X or X+1 ?)

Hope this helps. :-)

Good luck!

Regards,
Erwin Moller

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация